问题 如何自定义LaTeX中对子列表的引用?


我的LaTeX文档中有一个列表/子列表结构。默认情况下,子列表用字母分隔,因此您最终得到:

1. Item
    (a) sub item
    (b) sub item

在我的文档中,我有超过26个子项,所以我遇到了一个计数器溢出错误,我通过重写子项标签来修复,所以它们现在看起来像这样

1. Item
    1.1 sub item
    1.2 sub item

我在其中一个项目上放了一个标签,以便我稍后可以参考具体步骤。问题是,渲染引用时,它使用字母而不是子项的编号进行渲染。

这是一个显示问题的示例文档。

\documentclass[11pt]{report}

\begin{document}

\renewcommand{\labelenumii}{\arabic{enumi}.\arabic{enumii}}

\begin{enumerate}
    \item Item
    \begin{enumerate}
        \item \label{lbl} Label here
    \end{enumerate}
\end{enumerate}

Ref: \ref{lbl}

\end{document}

这会像这样呈现:

1. Item
    1.1 Label here
Ref: 1a

所以不是说“Ref:1.1”,而是使用“Ref:1.a”。有没有办法让\ ref使用源枚举的编号?如果没有,无论如何都要生成对超过26个项目的子列表中项目的正确引用?


11611
2018-03-27 20:28


起源



答案:


我正在查看我的The LaTeX Companion副本,第129页,从我看到的内容我会建议如下:

\renewcommand{\theenumii}{\arabic{enumii}}
\renewcommand{\labelenumii}{\theenumi.\theenumii.}
\makeatletter
\renewcommand{\p@enumii}{\theenumi.}
\makeatother

但是,我目前无法访问正在运行的LaTeX环境来测试它。


10
2018-03-27 20:41



这样做 - 我真的需要得到那本书。谢谢! - Matt McMinn
也可以使用\ usepackage {fncylab} - Ma Ming


答案:


我正在查看我的The LaTeX Companion副本,第129页,从我看到的内容我会建议如下:

\renewcommand{\theenumii}{\arabic{enumii}}
\renewcommand{\labelenumii}{\theenumi.\theenumii.}
\makeatletter
\renewcommand{\p@enumii}{\theenumi.}
\makeatother

但是,我目前无法访问正在运行的LaTeX环境来测试它。


10
2018-03-27 20:41



这样做 - 我真的需要得到那本书。谢谢! - Matt McMinn
也可以使用\ usepackage {fncylab} - Ma Ming


因此对于2个嵌套列表,应该按以下方式完成:

\begin{enumerate}
\renewcommand{\theenumi}{\arabic{enumi}}
\renewcommand{\theenumii}{\arabic{enumii}}
\renewcommand{\theenumiii}{\arabic{enumiii}}

\renewcommand{\labelenumi}{\theenumi.}
\renewcommand{\labelenumii}{\theenumi.\theenumii.}
\renewcommand{\labelenumiii}{\theenumi.\theenumii.\theenumiii.}

\makeatletter
\renewcommand{\p@enumii}{\theenumi.}
\renewcommand{\p@enumiii}{\theenumi.\theenumii.}
\makeatother

...

\end{enumerate}

我花了太多时间来理解它。 我希望这有帮助,因为这个线程帮助了我。

谢谢。


3
2018-05-18 08:18