【发布时间】:2018-04-11 07:38:47
【问题描述】:
我声明了一个包含\caption 和\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 ??)"
我知道之前已经问过类似的问题,但它与新环境无关。 How to reference a label within a newcommand in LATEX?
【问题讨论】: