list - 如何自动创建 LaTeX 文档中使用的项目列表?

标签 list latex automation 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.}

它将以特殊方式格式化,以方便读者将其识别为提示。它有一个标签,可以在示例中用 '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/

相关文章:

python - 如何增加列表中每个项目/元素的值?

c# - 忽略其中一个字段的列表中不同项目的数量

python - 在列表中查找离今天最近的日期

c# - 以编程方式访问 Excel 自定义文档属性

linux - 如何自动创建和配置 VPS 服务器?

python - 迭代相同元素的列表

java - 将源代码转换为 LaTeX

latex - PStricks 和 TikZ 如何比较易于学习和 API 设计的质量?

macros - 如何在 Latex 的新命令中添加空行

python - 对于 Electron 应用程序,可以将 Selenium 与 Python 一起使用吗?