5

I would like a Table of Contents that lists page numbers on the left, without dotted lines or the like. The items to be included are \section* items, which I gather can only end up on the ToC through using \addcontentsline. See the image for how it should look (I have a strong suspicion that the image was produced through abuse of enumerate, which I'd rather not do for obvious reasons).

sample

EDIT: Now that I'm on a computer with a physical keyboard, and can type up a little faster:

The document is a journal, with papers formatted as sections. Currently papers have the rough form:

\section*{Title}

\textbf{Author}\\
\textit{Institution}\\

Lorem ipsum...
\subsection{Introduction}
\subsubsection{Definitions}
...
\subsection*{References}

Note the paper title is unnumbered, while subsections within the paper are numbered. I'd like to be able to automatically produce a ToC containing paper titles and authors in the format and arrangement pictured. I'm fully amenable to producing a macro for the start of papers (ie something like \newpaper{Title}{Author}{Institution} that expands to the above). I've tried reading the documentation for titletoc and tocloft but am finding it all somewhat opaque to say the least.

The preamble currently uses a hefty pile of packages including fancyhdr, so I'd prefer a solution with minimal colateral damage if that's possible.

Moriambar
  • 11,466
dbmag9
  • 1,411

1 Answers1

8

From your example I assume that all of your sections are unnumbered. In that case you should not use \section* but normal \section commands and simply chance the counter that decides to what level headings are numbered, e.g.,

\setcounter{secnumdepth}{0}

If this is done then all such sections will show up in the ToC automatically.

As to formatting the entries as desired, use the titletoc package, that allows you to achieve such results with ease. You can for example find an example here: List all sections in TOC in one line wrapped but also in many other places on this site.

Update

Ok, so the situation changed a bit after the edit in the question. In other words the \section* commands are used for paper titles and then \subsection etc form the heading commands within a paper. This is probably not the best possible approach for a number of reasons, e.g., the subsections missing a section command will display 0.1 etc, but most importantly it means that a single paper can't be written using the article class. but okay, so be it :-)

So try something like this instead:

\documentclass{article}

\newcommand\newpaper[3]{% \clearpage \section*{#1}% \addcontentsline{toc}{section}{#1\tocauthor{#2}\tocinstitution{#3}} \textbf{#2}\ \textit{#3}\par \vspace{5mm}% }

\newcommand\tocauthor[1]{\\textmd{#1}} \newcommand\tocinstitution[1]{}

\usepackage{titletoc}

\titlecontents{section}[3pc] {\addvspace{1.4pc}\bfseries} {}{{\hspace*{-3pc}\makebox[3pc]{\thecontentspage.\hfil}}}{}[\addvspace{.2pc}]

\renewcommand\thesubsection{\arabic{subsection}}

\setcounter{tocdepth}{1}

\begin{document}

\tableofcontents

\newpaper{this is the title of the first paper}{author}{inst}

Lorem ipsum... \subsection{Introduction} \subsubsection{Definitions} ... \subsection*{References}

\newpaper{And here the title of the second paper}{author2}{inst2}

\end{document}

Can't show you the output as I have no idea how to include a picture into this text from the iPad and that's the device I currently have available.

The code above does a bunch of hard wired setting that would need to be adjusted to taste but it does generate roughly the design of the given example in the question. As to the titletoc documentation, I don't think it is so difficult to understand but yes one might need to invest a minute or two.

  • Within the text, sections have subsections (and subsubsections) which do need numbering; your code suppresses that also. I'm afraid I'm not sure I can agree with your 'with ease' regarding titletoc either... – dbmag9 Jul 23 '13 at 15:41
  • Holy hell that's phenomenal, thank you so much. I may be back with confusion as to what certain parts of that code do, but I think for the most part I should be able to play with it and figure things out. – dbmag9 Jul 24 '13 at 10:59