テーブルに番号を付けたいのですが、例えば
Theorem 1.3
Table 1.4
Lemma 1.5
この結果をどのように達成できますか? 私も cleveref を使用しているので、理想的には、\cref{ThatTable}
完了したらリンクされた「表 1.4」も生成します。
答え1
特に何もする必要はありませ\newtheorem{theorem}[table]{Theorem}
ん。
\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}
ただし、 の浮動性により、table
出力が「同期していない」ように見える場合があることに注意してください。
答え2
assoccnt
これは、関連するカウンター(パッケージまたはxassoccnt
)の相互割り当てによって実現できます。
時間が増加するたびにTheorem
、テーブル カウンターも増加する必要があり、その逆の場合も同様に、lemma
環境がカウンターを使用するTheorem
ため、これも増加します。
この連続カウントの使用は、フローティングテーブルがカウントを「中断」する可能性があるため、フローティングテーブルを防ぐ必要があります。
\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}