2

This question already has an answer here:

I would like to number my table so that I have, e.g.

Theorem 1.3

Table 1.4

Lemma 1.5

How can I achieve this result? I am also using cleveref, so ideally \cref{ThatTable} would produce a linked ``Table 1.4'' when I am done as well.

marked as duplicate by Mico tables Dec 9 '14 at 8:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This requires either a common counter for theorems, lemma and tables or another, more sophisticated approach. Please provide a MWE in order to get some quick help – user31729 Dec 9 '14 at 8:24
3

You have to do nothing particular: \newtheorem{theorem}[table]{Theorem} will do.

\documentclass{book}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{cleveref}

\newtheorem{theorem}[table]{Theorem}

\begin{document}
\chapter{My content}

\begin{theorem}\label{A}
\end{theorem}

\begin{table}
  \caption{A dummy table}\label{B}
\end{table}

\begin{theorem}\label{C}
\end{theorem}

\begin{theorem}
\end{theorem}

See \cref{A}, \cref{B}, \cref{C}.

\begin{table}
  \caption{Another dummy table}
\end{table}

\end{document}

Note, however, that the floating nature of table may make the output to appear “out of sync”.

enter image description here

  • Unfortunately, I get this. LaTeX Error: Command \theorem already defined. Or name \end... illegal, see p.192 of the manual. It seems to be in part because I have this: \newtheorem{theorem}[thm]{Theorem}. But if I remove that, the document doesn't seem to know what a Theorem is anymore. – jdc Dec 9 '14 at 10:11
  • @jdc Not with my example. – egreg Dec 9 '14 at 10:30
  • Yes, your example, all alone, does the right thing, but sadly, I am unable to integrate into my existing code in a way that doesn't give an error. I was wondering if you had any advice on how I can fix this problem. If not, I understand; in any event, I didn't mean to cast aspersions on your example, which works beautifully. – jdc Dec 9 '14 at 23:09
  • @jdc Sorry, but without seeing the code and the setup it's impossible to say anything sensible. Open a new question, with a MWE. – egreg Dec 9 '14 at 23:24
2

This could be achieved with the mutally assignment of associated counters (package assoccnt or xassoccnt)

Each time Theorem is increased, the table counter should be increased as well and vice versa, the lemma environment uses the Theorem counter, so this will be increased too.

The usage of this continous counting should prevent floating tables, as those might 'interrupt' the counting

\documentclass{book}


\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{assoccnt}


\newtheorem{Theorem}{Theorem}
\newtheorem{lemma}[Theorem]{lemma}


\DeclareAssociatedCounters{Theorem}{table}%
\DeclareAssociatedCounters{table}{Theorem}%   



\begin{document}
\chapter{My content}

\begin{Theorem}
\end{Theorem}

\begin{table}
  \caption{A dummy table}
\end{table}


\begin{Theorem}
\end{Theorem}


\begin{Theorem}
\end{Theorem}



\begin{table}
  \caption{Another dummy table}
\end{table}

\begin{lemma}
 First lemma
\end{lemma}


\begin{table}
  \caption{Another dummy table}
\end{table}

\begin{Theorem}
\end{Theorem}




\end{document}

enter image description here

  • The \cref works as expected – user31729 Dec 9 '14 at 8:46

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