我想在 LaTeX 文档中添加项目。例如,我想向文档添加提示。我创建了一个命令,所以我可以调用类似的东西:
\hint{foocareful}{Be careful with foo!}{foo is a very precious item and can easily be broken. Be careful, especially don't throw foo.}
它将以特殊方式格式化,以方便读者将其识别为提示。它有一个标签,可以在示例中用 'foocareful' 引用。
在附录中,我想添加所有提示的列表以及对它们的引用。类似的东西:
\begin{enumerate}
...
\item Be careful with foo! (\pageref{foocareful})
...
\end{enumerate}
但我自然不想手工维护这个列表。如何自动创建这样的列表?
最佳答案
一种方法是使用 float
包裹。我认为,至少,floatrow
package 也可以为所欲为,也可能更加灵活。不过见。
这是您尝试使用 float
执行的操作的示例:
\documentclass{article}
\usepackage{float}
\floatstyle{boxed}
\newfloat{hintbox}{H}{hnt}
\floatname{hintbox}{Hint}
\newcommand\hint[2]{%
\begin{hintbox}
#2
\caption{#1}
\end{hintbox}}
\begin{document}
\section{Hello}
\hint{Be careful with foo!\label{foocareful}}{%
foo is a very precious item and can easily be broken.
Be careful, especially don't throw foo.}
\hint{Don't worry about bar!\label{foocareful}}{%
Unlike foo, bar is pretty easily to get along with.}
\section{End}
\listof{hintbox}{List of Hints}
\end{document}
关于list - 如何自动创建 LaTeX 文档中使用的项目列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/285816/