[Tex/LaTex] Custom numbering of tables, equations and figures

floatsnumbering

I am writing a chapter for a book. The chapter number is 5.4. The chapter has multiple sections. I would like all the figures, tables and equations in my chapter to be labelled as 5.4.X. For example, the first equation should be labelled as 5.4.1, the first table should be labelled as Table 5.4.1, the first figure should be labelled as Figure 5.4.1, and so on. How should I do this? I am writing this chapter independently and I do not have access to any files, etc. that will be used for the final typesetting. I am using documentclass article for writing the chapter.

Best Answer

You could add the following instructions to the document's preamble:

\newcommand{\chprefix}{5.4}
\renewcommand\theequation{\chprefix.\arabic{equation}}
\renewcommand\thefigure{\chprefix.\arabic{figure}}
\renewcommand\thetable{\chprefix.\arabic{table}}

That way, if the publisher decides to change the chapter number from 5.4 to, say, 6.7, only the \chprefix macro needs to be adjusted.

A full MWE:

enter image description here

\documentclass{article}

\newcommand{\chprefix}{5.4}
\renewcommand\theequation{\chprefix.\arabic{equation}}
\renewcommand\thefigure{\chprefix.\arabic{figure}}
\renewcommand\thetable{\chprefix.\arabic{table}}

\begin{document}
\begin{equation} \label{eq:first} a^2+b^2=c^2 \end{equation}

\setcounter{figure}{5}
\begin{figure}[h] \caption{A figure} \label{fig:middle} \end{figure}

\setcounter{table}{19}
\begin{table}[h] \caption{A table} \label{tab:last} \end{table}

Cross-references to equation (\ref{eq:first}), figure \ref{fig:middle}, and table \ref{tab:last}.

\end{document}
Related Question