Custom list of things in LaTeX?
I'm writing a script for college where I insert the date of a part of text apart from the chapters using a custom command (currently just displaying a marginpar
), like:
\lesson{1}
\section{A}
\section{B}
\subsection{C}
\lesson{2}
\subsection{D}
Apart from the usual \listoffigures
, \listoftables
and \tableofcontents
I want a list that allows access by lesson number. It should look like the \listoffigures
except with a custom label (since the lessons don't h开发者_StackOverflow中文版ave captions), for example:
Lesson 1 ..... Page 1
Lesson 2 ..... Page 5
Is there a package that allows me to define new lists like that as easy as creating new counters? Or do I have to dig into the source for the existing lists and hack my own?
(the memoir
package documentation has a list of rendered examples at the beginning, that would be another example of a custom list like I need it)
Any keywords to google for are appreciated!
I would do the following:
1) Open a file at the beginning:
\newwrite\listoffoo
\immediate\openout\listoffoo=\jobname.foo
2) Each command like \lesson
should put a line into the file:
\newcounter{lesson}
\def\lesson{%
...
\refstepcounter{lesson}%
\immediate\write\listoffoo{%
\string\lessonfooline{\ref{lesson}}{\pageref{lesson}}}
...
}
3) At the end of the processing, close the file and read it in:
\immediate\closeout\listoffoo
\input\jobname.foo
You'll have to define the commands like \lessonfooline
.
Hope this outline helps.
精彩评论