I have several hundred exercises in form
\begin{exercise}
\end{exercise}
where each one is a small own file.
I input those through \input{...}
on master documend.
I have done some other questions about these exercises and I explain
my purpose here
Here's my question: it is possible the numbering of the exercises shown in
my final .pdf document to appear somehow automatically through loops in a tabular
with three columns where the first column shows the chapter to which exercise belongs,
in the second column is the number of exercise and the third column
is a page on which the exercise occurs.
Unfortunately I do not know if this is possible and obviously
if it is possible how could to become … for this reason I can not
give my own example.
All I can think of is via \label
\ ref
but this
I think it's quite hard to be done every time I decide to introduce some
exercise in the middle of the text, I must modify whole table
Below is the structure of my document
\documentclass[a4paper,10pt]{book}
\usepackage[utf8x]{inputenc}
\newtheorem{exercise}{\Large \bfseries}[chapter]
\begin{document}
\chapter{kinetic }
\input{exercise.435.tex}
\chapter{momentum}
\input{exercise.436.tex}
\end{document}
and the exercise.435.tex
, exercise.436.tex
:
\begin{exercise}
Here is the text of the exercise
\end{exercise}
Best Answer
With package
etoc
you can use a table of contents for that.\etocname
,\etocnumber
and\etocpage
are whatetoc
extracts from the.toc
file. Here I used\etocnumber
as it will contain already the chapter number. The code is set-up so that the 'name' of the exercise, as written to the.toc
file is the number of the chapter. So\etocname
gives this number if needed.With hyperref, these things are links (use hyperref option
linktoc=all
to have also the page numbers linked).Edit 1: I have added some final touches to achieve grid-like typesetting. As one knows this is always somewhat difficult in TeX, with all the interline glues and so on added. I replace the images of the output with new ones, with the links colored to show that they are indeed links.
Note that this fancy looking update has nothing to do with the original problem, it is just a question of finalizing the looks of the output, in the chosen multi-columned style. (update: a simpler method is indicated in the commented-out code).
Edit 2: I add a variant to the macro
\exercisetotoc
which avoids the creation byhyperref
of a bookmark for each exercise (showing up in the final pdf file). Depending on the case, one may or may not want to have such bookmarks created byhyperref
. In both variants though, the exercise numbers in the list produced byetoc
are correctly hyperlinked.Nota Bene: this use of
\tableofcontents
to getetoc
to display the list of exercises does not at all preclude a standard\tableofcontents
in the document. Assume for example we have chapters, sections and subsections. They are at levels 0, 1, and respectively 2, inetoc
linguo. Thendisplays a completely standard table of contents, with chapters (also parts possibly), sections and subsections. Later in the document
In this way one can use
etoc
to selectively prints "list of.." anything, all of that with a single.toc
file...