LaTeX, by default, uses two-part style of figure, table and equation numbers (like Figure 1.3). I used to have 3-part numbers (chapter.section.object number). To achieve this in LaTeX, I use the following code (example for table):
Code: Select all
\renewcommand{\thetable}{\thesection.\arabic{table}}
However, when I try to put table before first section begins, it returns zero as section number (table number looks like 1.0.5). This is undesired behavior, I want to have two-part numbering before first section (like 1.5).
MWE:
Code: Select all
\documentclass{report}
\renewcommand{\thetable}{\thesection.\arabic{table}}
\begin{document}
\chapter{foo}
\begin{table}[htp!]
\caption{Table outside section}
\begin{tabular}{|c|}
qwerty
\end{tabular}
\end{table}
\section{First section}
\begin{table}[htp!]
\caption{Table inside section}
\begin{tabular}{|c|}
qwerty
\end{tabular}
\end{table}
\end{document}
I tried to use ifthen to detect, if I am inside or outside a section with this code:
Code: Select all
\usepackage{ifthen}
...
\ifthenelse{\equal{\arabic{section}}{0}}{we are outside}{we are inside}
This works inside text, but not within \renewcommand (undefined control sequence). What's wrong?