假设我写了两次表格,并希望第二个表格的编号与第一个表格相同。对于方程式,我知道如何做到这一点。但是,对于表格,这行不通。以下是我所想的,但却出现了错误:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
x = 1
\label{eq1}
\end{equation}
\begin{equation}
x \not= 2
\tag{\ref{eq1}}
\end{equation}
\begin{table}[h]
\begin{tabular}{c}
hello
\end{tabular}
\caption{this is a talbe}
\label{table}
\end{table}
\begin{table}[h]
\begin{tabular}{c}
hello
\end{tabular}
\caption{this is a talbe}
\tag{\ref{table}}
\end{table}
\end{document}
有人知道如何正确引用吗?
答案1
这里有一个技巧。\tabtag{table}
在之前使用\caption
。
\documentclass{article}
\usepackage{amsmath}
\newcommand{\tabtag}[1]{%
\renewcommand{\thetable}{\ref{#1}}%
\addtocounter{table}{-1}}
\begin{document}
\begin{equation}
x = 1
\label{eq1}
\end{equation}
\begin{equation}
x \not= 2
\tag{\ref{eq1}}
\end{equation}
\begin{table}
\begin{tabular}{c}
hello
\end{tabular}
\caption{this is a table}
\label{table}
\end{table}
\begin{table}
\begin{tabular}{c}
hello
\end{tabular}
\tabtag{table}
\caption{this is a table}
\end{table}
\begin{table}
\begin{tabular}{c}
hello
\end{tabular}
\caption{this is a table}
\end{table}
\end{document}