2

I’m writing my PhD thesis using this template. The template offers two ways of enumerating figures, tables, and equations, namely, continuous numbering and by chapters. According to the comments provided by the template developer, one should change the arguments of the \setcounter command in order to switch between these numbering modes (0 – by chapter, 1 - continuous). With the current settings, the numbering of tables is continuous whereas the numbering of figures and equations is by chapter. What I need is to set continuous numbering for all three. However changing arguments of \setcounter{contnumeq} and \setcounter{contnumfig} commands leads to errors, so does changing 0 to 1 in \ifthenelse{\equal{\thecontnumeq} and \ifthenelse{\equal{\thecontnumfig}.

\documentclass[12pt,a4paper]{extreport}

\usepackage{cmap}                           
\usepackage[T2A]{fontenc}       
\usepackage[utf8]{inputenc}         
\usepackage[english,russian]{babel} 
\usepackage{amsthm,amsfonts,amsmath,amssymb,amscd}
\usepackage{mathtools} 
\usepackage{tikz}
\usepackage{caption} 
\usepackage{chngcntr}

\usepackage{ifthen}
\newcounter{contnumeq}
\newcounter{contnumfig}
\newcounter{contnumtab}

\setcounter{contnumeq}{1}           % Нумерация формул: 0 --- пораздельно (во введении подряд, без номера раздела); 1 --- сквозная нумерация по всей диссертации
\setcounter{contnumfig}{1}          % Нумерация рисунков: 0 --- пораздельно (во введении подряд, без номера раздела); 1 --- сквозная нумерация по всей диссертации
\setcounter{contnumtab}{1}

\ifthenelse{\equal{\thecontnumeq}{0}}{%
    \counterwithout{equation}{chapter} % Убираем связанность номера формулы с номером главы/раздела
}
\ifthenelse{\equal{\thecontnumfig}{0}}{%
    \counterwithout{figure}{chapter}   % Убираем связанность номера рисунка с номером главы/раздела
}
\ifthenelse{\equal{\thecontnumtab}{1}}{%
    \counterwithout{table}{chapter}    % Убираем связанность номера таблицы с номером главы/раздела
}

\begin{document}

\chapter{First}

\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        \draw (0,0) circle (1cm);
    \end{tikzpicture}
    \caption{Circle1}
    \label{fig1}
\end{figure}

\begin{table}[h]
    \centering
    \caption{Table1}
    \label{table1}
    \begin{tabular}{cc}
        \textbf{first row}  & \textbf{second row} \\
        firs cell   & second cell  \\
        third cell  & fourth cell  \\
    \end{tabular}
\end{table}

\begin{equation}
\overline{A} \vee \overline{B} \equiv \overline{A \wedge B}
\end{equation}

\chapter{Second}

\begin{figure}[h]
    \centering
    \begin{tikzpicture}
    \draw (0,0) circle (1cm);
    \end{tikzpicture}
    \caption{Circle2}
    \label{fig2}
\end{figure}

\begin{table}[h]
    \centering
    \caption{Table2}
    \label{table2}
    \begin{tabular}{cc}
        \textbf{first row}  & \textbf{second row} \\
        firs cell   & second cell  \\
        third cell  & fourth cell  \\
    \end{tabular}
\end{table}

\begin{equation}
\overline{A} \wedge \overline{B} \equiv \overline{A \vee B}
\end{equation}

\end{document}
  • 1
    Rather than setting counters, remove the \newcounter, \setcounter and \ifthenelse statements and just put \counterwithout{equation}{chapter} \counterwithout{figure}{chapter} \counterwithout{table}{chapter}. – Werner Jul 11 '16 at 17:01
2

The example for the table continous counting works just by chance since \ifthenelse requires three arguments, not just two of them.

\ifthenelse{test condition}{true branch}{false branch}

Omitting the false branch for the first two examples must fail since it tries to read the next \ifthenelse etc. For the last one LaTeX assumes that the last argument is empty.

\documentclass[12pt,a4paper]{extreport}

\usepackage{cmap}                           
\usepackage[T2A]{fontenc}       
\usepackage[utf8]{inputenc}         
\usepackage[english,russian]{babel} 
\usepackage{amsthm,amsfonts,amsmath,amssymb,amscd}
\usepackage{mathtools} 
\usepackage{tikz}
\usepackage{caption} 
\usepackage{chngcntr}

\usepackage{ifthen}
\newcounter{contnumeq}
\newcounter{contnumfig}
\newcounter{contnumtab}

\setcounter{contnumeq}{1}           % Нумерация формул: 0 --- пораздельно (во введении подряд, без номера раздела); 1 --- сквозная нумерация по всей диссертации
\setcounter{contnumfig}{1}          % Нумерация рисунков: 0 --- пораздельно (во введении подряд, без номера раздела); 1 --- сквозная нумерация по всей диссертации
\setcounter{contnumtab}{1}

\ifthenelse{\equal{\thecontnumeq}{1}}{%
    \counterwithout{equation}{chapter} % Убираем связанность номера формулы с номером главы/раздела
}{}
\ifthenelse{\equal{\thecontnumfig}{1}}{%
    \counterwithout{figure}{chapter}   % Убираем связанность номера рисунка с номером главы/раздела
}{}
\ifthenelse{\equal{\thecontnumtab}{1}}{%
    \counterwithout{table}{chapter}    % Убираем связанность номера таблицы с номером главы/раздела
}{}

\begin{document}

\chapter{First}

\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        \draw (0,0) circle (1cm);
    \end{tikzpicture}
    \caption{Circle1}
    \label{fig1}
\end{figure}

\begin{table}[h]
    \centering
    \caption{Table1}
    \label{table1}
    \begin{tabular}{cc}
        \textbf{first row}  & \textbf{second row} \\
        firs cell   & second cell  \\
        third cell  & fourth cell  \\
    \end{tabular}
\end{table}

\begin{equation}
\overline{A} \vee \overline{B} \equiv \overline{A \wedge B}
\end{equation}

\chapter{Second}

\begin{figure}[h]
    \centering
    \begin{tikzpicture}
    \draw (0,0) circle (1cm);
    \end{tikzpicture}
    \caption{Circle2}
    \label{fig2}
\end{figure}

\begin{table}[h]
    \centering
    \caption{Table2}
    \label{table2}
    \begin{tabular}{cc}
        \textbf{first row}  & \textbf{second row} \\
        firs cell   & second cell  \\
        third cell  & fourth cell  \\
    \end{tabular}
\end{table}

\begin{equation}
\overline{A} \wedge \overline{B} \equiv \overline{A \vee B}
\end{equation}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.