我声明了一个包含 a\caption
和 a的新环境,\label
所以我可以引用它。
在我的标题中:
\DeclareFloatingEnvironment[name=Tableau]{tableau}
\newenvironment{ptab}{\captionsetup{type=tableau}}{}
在我的 .tex 文件中:
\begin{ptab}
\caption{A caption for my table}
\label{ptab:myTab}
\end{ptab}
Some text with a reference (Tableau~\ref{ptab:myTab}) % Works fine !
问题:我想通过声明一个\newcommand
可以为我写这个来获得一些时间。但是文本中的引用不再起作用了!
在我的标题中添加:
\newcommand{\tabref}[2]{%
\begin{ptab}
\label{#1}
\caption{#2}
\end{ptab}}
在 .tex 文件中:
\tabref{ptab:myTab}{A caption for my table}
Some text with a reference (Tableau~\ref{ptab:myTab}) % Not working "(Tableau ??)"
我知道之前已经问过类似的问题,但它与新环境无关。 如何在 LATEX 的新命令中引用标签?