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?

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}

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.


Need Your Help

Creating a workload on a sample database

sql sql-server sql-server-2008 tsql sql-server-2005

I have to create a sample database and create a transactional workload of 10-15 gigs.

SSAS - MDX Query Performance Issue

performance sql-server-2008 ssas mdx

I have an MDX query referencing a SQL Server Analysis Services 2008 R2 Enterprise Edition cube that from a functional standpoint returns the data that is needed accurately and correctly. It takes 5...