Mne*_*nth 12 automation latex list tex
我想在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.}
Run Code Online (Sandbox Code Playgroud)
这将以特殊方式格式化,以便读者将其识别为提示.它获得了一个标签,可以在示例中用'foocareful'引用.
在附录中,我想添加一个包含引用的所有提示的列表.就像是:
\begin{enumerate}
...
\item Be careful with foo! (\pageref{foocareful})
...
\end{enumerate}
Run Code Online (Sandbox Code Playgroud)
但我自然不想手工维护这个清单.如何自动创建这样的列表?
一种方法是使用float包.我认为,至少,floatrow包装也可以做你想要的,也可能更灵活.不过,请你去.
以下是您尝试使用的示例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}
Run Code Online (Sandbox Code Playgroud)