Customize Cross Reference Items in LaTeX
ChenZhijin
.com

Customize Cross Reference Items in LaTeX

Customize Cross Reference Items in LaTeX

When we want to include some figures or equations that we want to cross-reference later, we write our LaTeX like below:

1
2
3
4
5
6
\begin{figure}
\centering
\includegraphics[scale=0.5]{images/cat.png}
\caption[Cat]{A long name of the cat and description of the figure.}
\label{fig:cat}
\end{figure}

When we reference it, we write:

1
\ref{fig:cat}

To get:

Figure 1: Cat

This works for most of the times. When what if we want to define another category of items, with independent counter and a name different from “Figure”?

In this case, we have to define our own environment. For example, we have a series of compounds, and we want to make a list of them so we can reference them later. We define a new environment called compound.

1
2
3
4
\floatstyle{plain}
\newfloat{compound}{thp}{cpd}
\floatname{compound}{Compound}
\renewcommand*{\thecompound}{\textbf{\arabic{compound}}}

More content updating…

Tagged with: