Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create automatic a list of items used in a LaTeX-document?

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?

like image 270
Mnementh Avatar asked Nov 12 '08 23:11

Mnementh


People also ask

How do you continue enumerate in LaTeX?

The environment where this happens is called cenumerate-- as in, continuing to enumerate. To employ this environment at any level k in i, ii, iii or iv, just employ the command \renewcommand{outlinek}{cenumerate} before the start of your outline. Be warned, this will even continue to count across outlines!

What is itemize in LaTeX?

Itemize: This is an environment used for bulleted list basically when the given details or information or to be put in an unordered list. Enumerate: This is an environment used for numbered list.

Which environment in LaTeX is used to generate a numbered list?

the itemize environment for creating a bulleted (unordered) list. the enumerate environment for creating a numbered (ordered) list.


1 Answers

One way to do it is to use the float package. I think that, at least, the floatrow 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:

\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}
like image 134
Will Robertson Avatar answered Nov 03 '22 22:11

Will Robertson