如何自动创建 LaTeX 文档中使用的项目列表?
我想在 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}
但我自然不想手动维护这个列表。 如何自动创建这样的列表?
I want to add items in a LaTeX-document. Say for example, that I want add hints to the document. I create a command, so I can call something similar to this:
\hint{foocareful}{Be careful with foo!}{foo is a very precious item and can easily be broken. Be careful, especially don't throw foo.}
This will be formatted in special way, to make it easy for the reader to recognize it as a hint. It gets a label, that can be referenced in the example with 'foocareful'.
In the appendix I want to add a list of all hints with references to them. Something like:
\begin{enumerate}
...
\item Be careful with foo! (\pageref{foocareful})
...
\end{enumerate}
But naturally I don't want to maintain this list by hand. How can I create automatically such a list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种方法是使用
float
包。 我认为,至少,floatrow
包也可以做你想做的事情,而且可能还更灵活。 不过,再见。这是您尝试使用
float
执行的操作的示例:One way to do it is to use the
float
package. I think that, at least, thefloatrow
package can also do what you want, and may also be more flexible. See you go, though.Here's an example of something like you're trying to do using
float
:已经很多年没有这样做了,但我会查看 \tableofcontents 和 \listoffigures 的 LaTeX 源代码。 我认为该机制是通用的,您可以将其扩展以包含您自己的列表。
Have not done this in years, but I would look at the LaTeX source code for \tableofcontents and \listoffigures. I think the mechanism is generic and you can expand it to include your own lists.