I'm pretty close to being a LaTeX beginner. I'm hoping to use the comment package to indicate author's names (i.e. who's responsible for writing) on each section of a shared paper. This could then temporarily be shown in the TOC.
But in the manual: "with the opening and closing commands again on a line of their own."
Clearly my code won't work and I'm not clear how to solve it. Any recommendations?
Much appreciated!
Michael
\documentclass[10pt,letterpaper]{article}
\usepackage{comment}
\includecomment{sectionauthor}
\begin{document}
\section{First Section \sectionauthor Me \endsectionauthor }
\section{Second Section \sectionauthor You \endsectionauthor }
\end{document}
Best Answer
Here's a way to do it: the command
\sectionauthor
must have two different meanings and we accomplish it by changing its definition inside a group when we typeset the table of contents.I use
\newrobustcmd
frometoolbox
because it's more practical than the standard\DeclareRobustCommand
. It's necessary to declare\sectionauthor
as robust, because this will make LaTeX write it unmodified in the.toc
file, so we can use it also for giving it a new meaning.I have applied some formatting instructions, modify them to suit your needs.
You can implement a “toggle on and off” on the two possibilities:
The output without commenting (a
%
in front of the line suffices) the two lines is the same as above. If we comment only the first line, we getIf we comment only the second line we remove the names from the TOC, but leave them in the body. Commenting out both lines the names disappear completely.