I have a rather long file with certain information about topics (say, name of the topics and tags associated to it). I want to get an automatic table at the beginning of my document that summarizes this information (somewhat similar to a toc) in the following way: First column is the topic, second are the provided tags, third is the page where the topic is listed.
I want to achieve this through commands (say, \topic
and \tags
), that I use when starting the new topic and I want LaTeX to produce the table automatically, using the information gathered in all these commands.
Does anyone know how this can be done?
[No MWE provided since I don't even know how to start. I found it kind of hard to explain what I want to achieve, if it is not clear I can try to make it clearer.]
EDIT:
I will try to clarify what I want. In the following code
\documentclass{scrartcl}
\begin{document}
\begin{tabular}{lll}
Topic & Tags & Page \\
Topic 1 & A,B,C & 2 \\
Topic 2 & D,E & 3 \\
Topic 3 & A,E & 4
\end{tabular}
\newpage
Topic 1 \\ Tags A,B,C \newpage
Topic 2 \\ Tags D,E \newpage
Topic 3 \\ Tags A,E
\end{document}
I have three topics, each on a new page, with certain tags. On the first page I have a table that summarizes all topics that occur. I now want to have commands, say \topic
,\tag
, such that I can use \topic{Topic 1}
and \tag{A,B,C}
when Topic 1 starts, so that the respective row in the table will created automatically (and I don't have to put in the table manually at all).
EDIT 2: Maybe it is possible to adapt the code of the \newlistof
command from the tocloft
package to create a table (instead of a list), but I don't understand that well enough to do so.
\topic{..}
command followed by a\tags{..}
command? Or will you possibly have\tags{..}
scattered throughout the\topic
, and one would have to accumulate these into a single list (so that\tags{A}
...\tags{B}
...\tags{C}
is equivalent to\tags{A,B,C}
, even though the individual\tags
are on separate pages)? And the page is associated with the\topic
only, not the location of the\tags
, right?tag
command without problem so that nothing needs to be accumulated. Yes, the page that should occur in the table is the one where the topic starts.