我正在尝试创建一个包含单实例、编号列表的环境(以便我可以轻松控制间距等)。问题是我无法用于\ref
交叉引用枚举项。
MWE 的代码是:
\documentclass{article}
\newcounter{tesisc}
\AtBeginDocument{\setcounter{tesisc}{1}}
\newenvironment*{Tesis}
{\begin{list}
{$(\arabic{tesisc})$}
{\setlength{\rightmargin}{0cm}
\setlength{\leftmargin}{2\parindent}}
\item
}
{\end{list}\refstepcounter{tesisc}}
\begin{document}
\begin{Tesis}
Testing testing testing testing testing testing testing testing testing testing.
\label{th:one}
\end{Tesis}
\begin{Tesis}
Testing testing testing testing testing testing testing testing testing testing.
\label{th:two}
\end{Tesis}
This is one reference: \ref{th:one}. This is another reference: \ref{th:two}.
\end{document}
我的环境编号工作正常,但交叉引用则不然。
我怎样才能调整我的定义以便我的参考文献能够发挥作用?
答案1
您需要移动\refstepcounter
较早的,或者像这里使用\usecounter
这样list
设置\item
来增加计数器。
\documentclass{article}
\newcounter{tesisc}
\newenvironment*{Tesis}
{\begin{list}
{$(\arabic{tesisc})$}
{\setlength{\rightmargin}{0cm}
\refstepcounter{tesisc}\setlength{\leftmargin}{2\parindent}}
\item
}
{\end{list}}
\begin{document}
\begin{Tesis}
Testing testing testing testing testing testing testing testing testing testing.
\label{th:one}
\end{Tesis}
\begin{Tesis}
Testing testing testing testing testing testing testing testing testing testing.
\label{th:two}
\end{Tesis}
This is one reference: \ref{th:one}. This is another reference: \ref{th:two}.
\end{document}