I am trying to create a table of authorship for a report. I want it to look like a table of contents, only with the names of the authors instead of page numbers. I haven't had any luck looking online. Can anyone give me some advice?
Thanks in advance!
EDIT
Here's what I have so far:
\begin{center}
\rowcolors{1}{white}{light-gray}
\begin{tabular}{l r}
Table of Authorship \\ \hline
Section & Author \\
\hline
Introduction & Author \\
\hline
\hspace{1cm} Motivation & Author \\
\hline
\hspace{1cm} Background & Author \\
\hline
\end{tabular}
\end{center}
But as you guys can see, this is very brittle. If any section changes, the table will need to be updated. It would also be great if the numbers of the sections could be included as well.
EDIT 2
Second attempt at MWE:
\documentclass[a4paper]{article}
\usepackage[table]{xcolor}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[margin=0.5in]{geometry}
\usepackage{titlesec}
\graphicspath{ {figures/} }
\setcounter{secnumdepth}{4}
\definecolor{light-gray}{gray}{0.95}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\title{My MWE}
\author{Robocop}
\begin{document}
\maketitle
\pagebreak
\thispagestyle{empty}
\begin{center}
\rowcolors{1}{white}{light-gray}
\begin{tabular}{l r}
Table of Authorship \\ \hline
Section & Author \\
\hline
Introduction & Author \\
\hline
\hspace{1cm} Motivation & Author \\
\hline
\hspace{1cm} Background & Author \\
\hline
\end{tabular}
\end{center}
\end{document}
Best Answer
See the new version below, with some improvements/explanations
This is a first trial, but has some deficiencies.
.atl
file if changes have been made\subsection
etc. so far.Now, what's working?
I redefined the
\section
command to use additional[]
argument holding the author name. If empty, the argument value is empty too. In this redefined\section
command entries are written to an external file\jobname.atl
(atl stands for authorship table list)To prevent
\tableofcontents
writting into.atl
too, I patched\tableofcontents
to use the normal\section
command.The
\firsthead
should be replaced by\endhead
...Improved version
\jobname.atl
after changes to the\section...
nameslongtable
content)Explanations:
\let\LaTeXStandardSection\section
grabs the original definition of\section
and stores it to\LaTeXStandardSection
-- this way a redefinition by\RenewDocumentCommand{\section}
can use the old behaviour of\section
(which is needed here anyway) and add extra facilities to it. The same is true for\subsection
and\subsubsection
.The command argument list of
\section
is now {somO{}}, meaning **s**starred ...**o**ptional ... **m**andatory ... **O**ptional, i.e. the starred version of
\section`, then \section[toc-entry]{longer title} and later on the new optional argument for the author name, initially set to be empty (i.e. O{}).\RenewDocumentCommand{\section}...
checks if it's a starred section
\section*, using
\WriteATLSectionLine*{#3}{#4}with or
\WriteATLSectionLine{#3}{#4}`, which takes care whether the section number should be displayed or not.\AtBeginDocument
is executed before \begin{document}starts, so this can be used to open the output file for the entries. This is done via
\immediate\openout\authorfile=\jobname.atl. In addition, some starter code for the beginning for the longtableis written to the file already, as well the end code stuff in
\AtEndDocument`, in which the the file is closed.\immediate\write\authorfile{% }
is used to write stuff to the file, direct commands must be prepended with\string, whereas
\thesection` must be expanded right there, otherwise it would use the last section value of the document, not the relevant one.This is the content of the
\jobname.atl