Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am currently creating a template for transcripts (I don't know if this is the right word: you write a transcript if you have a (business) meeting and you want to record all important stuff that was said). The source is here.

The agenda items are currently in a simple enumerate-environment and as \section* in the source code. I would like to have only the section*{agenda item} written by the transcript writer. The list of all agenda items should get generated automatically. Ist this possible?

(Just to make that clear: I don't want to insert a table of contents! I want a simple

\begin{enumerate}[leftmargin=1.3em]%
    \setlength{\itemsep}{-2pt}% 
    \item agenda item 1
    \item agenda item 2
    \item agenda item 3
    \item agenda item 4
\end{enumerate}

which gets generated automatically)

share|improve this question
3  
It seems to me that is a table of contents, just with different formatting. Or at least that would be the most natural way to implement it in latex. just define \l@section which defines what is written to the toc file to write \item. –  David Carlisle Oct 30 '12 at 11:00
    
Is the template based on the article class? Are there also numbered sections or not? –  egreg Oct 30 '12 at 11:58
    
I use scrartcl class. No, I only use unnumbered sections (section*{bla}). –  moose Oct 30 '12 at 12:03

4 Answers 4

up vote 7 down vote accepted

One possible solution: the titlesec package was used to suppress the numbering for \sections in the document body; a redefinition of \l@section and \tableofcontents give the desired formatting as a list:

\documentclass{scrartcl}
\usepackage{titlesec}
\usepackage{lipsum}

\setcounter{tocdepth}{1}

\makeatletter
\renewcommand\tableofcontents{
\@starttoc{toc}
}
\renewcommand*\l@section[2]{%
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
    \addvspace{0.5em \@plus\p@}%
    \setlength\@tempdima{1.3em}%
    \begingroup
      \leavevmode
      \advance\leftskip\@tempdima
      #1\hfil\par
    \endgroup
  \fi}
\makeatother

\titleformat{\section}
  {\normalfont\Large\bfseries\sffamily}{}{0em}{}

\begin{document}

\tableofcontents
\section{Agenda item one}
\lipsum[4]
\section{Agenda item two}
\lipsum[4]
\section{Agenda item three}
\lipsum[4]
\section{Agenda item four}
\lipsum[4]

\end{document}

An image of the firs page, showing the list of sections:

enter image description here

share|improve this answer

I modify a little Gonzalo's method, in order to not hard-code the spacings and really use rather a true enumerate environment. (edit: to illustrate I add a \usepackage{enumerate}.) (edit2: I amend my original code which, in the case of options passed to the enumerate environment, compiled only if the toc file already existed...)


Edited: I propose three increasingly complicated methods. The first was a modification of Gonzalo's approach, in order to allow to use a real enumerate environment. For that, egreg has since provided a yet simpler way. Then I added support for subsections and subsubsections so that one could use formatting options of packages like enumitem to customize the look of the hacked table of contents (method 2). Finally (method 3) I modify once more to add hyperref support. So in the end we reconstitute a mock table of contents with possible hyperlinks. The links are put in the names of sections and subsections, but could also be inserted in the labels of the item (using enumitem). Page numbers are just not used. But if I understand the OP's aim would be more to use here an itemize environment, so I did not try to put the links in the item labels.

Here is for example how a table of contents with sections, subsections and subsubsections may appear:

example of a hacked table of contents

And all names (or letters for the subsubsections) are hyperref-links (the names are the ones used in the document body for the titles of the sections, subsections, subsubsections, they are not generated by the code). The code to get this is the third proposal below.


First proposal:

\documentclass{scrartcl}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{enumerate}

\setcounter{tocdepth}{1}

\newtoks\agendatoks
\newif\ifexisttoc

\makeatletter
\renewcommand\tableofcontents{%
\@starttoc{toc}\ifexisttoc
\begin{enumerate}[(A)] % <- customize this, for example if you use the
                  % enumitem package, to specify the spacings etc...
\the\agendatoks
\end{enumerate}
\fi}

\renewcommand*\l@section[2]{%
  \let\ex\expandafter
  \let\numberline\@gobble
  \ifnum \c@tocdepth >\z@
  \toks0=\ex{\ex\item #1}%
  \global\agendatoks=\ex\ex\ex{\ex\the\ex\agendatoks\the\toks0}%
  \global\existtoctrue
 \fi}

\makeatother

\titleformat{\section}
  {\normalfont\Large\bfseries\sffamily}{}{0em}{}

\begin{document}


\tableofcontents

\section{Agenda item one}
\lipsum[4]
\section{Agenda item two}
\lipsum[4]
\section{Agenda item three}
\lipsum[4]
\section{Agenda item four}
\lipsum[4]

\end{document}

Caveat: I did not look more than casually at the contents of a .toc file, so the method is only tested on the OP's Gonzalo's example!

png image of the dvi file


Second proposal:

% Time-stamp: <30-10-2012 21:26:48 CET jfb>
% http://tex.stackexchange.com/questions/79682/can-i-get-a-list-of-all-sections-as-a-simple-enumerate-list

\documentclass{article}
\usepackage{enumitem}  % to use its formatting options for enumerate, itemize, description
\usepackage{titlesec}  % to generate unnumbered sections and subsections in the body

%------------ macros to format the table of contents to one's arbitrary wishes
%------------ use is self-explanatory: customize \headeri, \headerii, \headeriii
%------------ none of the above two packages is necessary for the working of the macros

\newtoks\agendatoks
\newif\ifexisti
\newif\ifexistii
\newif\ifexistiii
\makeatletter

%------------ here we use options made available by package enumitem
\newcommand\headeri{\begin{enumerate}[font=\LARGE,label=\fbox{\arabic*}, itemsep=24pt]}
\newcommand\footeri{\end{enumerate}} % keep it in sync with \headeri!

\newcommand\headerii{\begin{enumerate}[font=\ttfamily\bfseries, leftmargin=1.5cm,%
 itemsep=18pt]}
\newcommand\footerii{\end{enumerate}}

\newcommand\headeriii{\begin{itemize}[itemsep=12pt]}
\newcommand\footeriii{\end{itemize}} 

%------------ our beautiful macros
\renewcommand\tableofcontents{%
\@starttoc{toc}%
\ifexisti
\the\agendatoks
\ifexistiii\footeriii\fi
\ifexistii\footerii\fi
\footeri
\fi}

\renewcommand\l@section[2]{%
  \let\ex\expandafter
  \let\numberline\@gobble
  \ifexistiii\toks0=\ex{\footeriii}\else\toks0={}\fi
  \global\existiiifalse
  \ifexistii\toks0=\ex{\the\toks0\noexpand\footerii}\fi
  \global\existiifalse
  \ifexisti\else\toks0=\ex{\headeri}\fi
  \global\existitrue
  \toks0=\ex{\the\toks0\noexpand\item}%
  \toks0=\ex\ex\ex{\ex\the\ex\toks0#1}%
  \global\agendatoks=\ex\ex\ex{\ex\the\ex\agendatoks\the\toks0}%
  % \showthe\agendatoks % for debugging
}

\renewcommand\l@subsection[2]{%
  \let\ex\expandafter
  \let\numberline\@gobble
  \ifexistiii\toks0=\ex{\footeriii}\else\toks0={}\fi
  \global\existiiifalse
  \ifexistii\else\toks0=\ex{\headerii}\fi
  \global\existiitrue
  \toks0=\ex{\the\toks0\noexpand\item}%
  \toks0=\ex\ex\ex{\ex\the\ex\toks0#1}%
  \global\agendatoks=\ex\ex\ex{\ex\the\ex\agendatoks\the\toks0}%
  % \showthe\agendatoks
}

\renewcommand\l@subsubsection[2]{%
  \let\ex\expandafter
  \let\numberline\@gobble
  \ifexistiii\toks0={}\else\toks0=\ex{\headeriii}\fi
  \global\existiiitrue
  \toks0=\ex{\the\toks0\noexpand\item}%
  \toks0=\ex\ex\ex{\ex\the\ex\toks0#1}%
  \global\agendatoks=\ex\ex\ex{\ex\the\ex\agendatoks\the\toks0}%
  % \showthe\agendatoks
}

\makeatother

% the following (from package titlesec) only influences the look of the body,
% not the table of contents
\titleformat{\section}
  {\normalfont\LARGE\bfseries\sffamily}{}{0em}{}
\titleformat{\subsection}
  {\normalfont\Large\sffamily}{}{1em}{}
\titleformat{\subsubsection}
  {\normalfont\large\ttfamily}{}{2em}{}

\begin{document}\thispagestyle{empty}

\centerline{\bfseries THIS IS THE TABLE OF CONTENTS}

\tableofcontents

\section{First}
\subsection{primo}
\subsection{secondo}
\subsubsection{i}
\subsubsection{ii}
\subsection{tertio}
\subsubsection{i}
\subsubsection{ii}
\subsubsection{iii}
\section{Second}
\subsection{primo}
\subsubsection{i}
\subsubsection{ii}
\subsubsection{iii}
\subsection{secondo}
\section{Third}
\subsection{tertio}
\section{Fourth}
\subsection{quarto}
\subsubsection{i}
\subsubsection{ii}
\subsubsection{iii}

\end{document}

Here is the first page:

enter image description here


Third proposal: with hyperref support (works also if hyperref is not there)

% Time-stamp: <31-10-2012 10:56:36 CET jfb>
% http://tex.stackexchange.com/questions/79682/can-i-get-a-list-of-all-sections-as-a-simple-enumerate-list

% Third version: now compatible with hyperref.

\documentclass{article}
\usepackage{enumitem}  % to use its formatting options for enumerate, itemize, description
\usepackage{titlesec}  % to generate unnumbered sections and subsections in the body
\usepackage{kantlipsum}

\usepackage{hyperref}

\newtoks\agendatoks
\newif\ifexisti
\newif\ifexistii
\newif\ifexistiii


%------------ here we use options made available by package enumitem
%------------ for the top level, and redefine \item for the inner levels

\makeatletter

\newcommand\headeri{\begin{enumerate}[font=\LARGE, %
                label=\fbox{\arabic*}, itemsep=18pt]%
                \sffamily\bfseries\Large}
\newcommand\footeri{\end{enumerate}} % keep it in sync with \headeri!

\newcommand\headerii{ \begingroup\normalfont\ttfamily(\def\item{, }\@gobble}
\newcommand\footerii{)\endgroup}

\newcommand\headeriii{\begingroup\scshape
                \let\item-$^\bgroup\hbox\bgroup\scriptsize\@gobble}
\newcommand\footeriii{\egroup\egroup$\endgroup} 

\makeatother


%------------ our beautiful macros
\makeatletter

\renewcommand\tableofcontents{%
\@starttoc{toc}%
\ifexisti
\the\agendatoks
\ifexistiii\footeriii\fi
\ifexistii\footerii\fi
\footeri
\fi}

\renewcommand\l@section[2]{%
  \let\@xp\expandafter
  \let\numberline\@gobble
  \def\hyper@linkstart{\noexpand\hyper@linkstart}%
  \def\hyper@linkend{\noexpand\hyper@linkend}%
  \edef\@jfbutmp{#1}%
  \ifexistiii\toks0={\footeriii}\else\toks0={}\fi
  \global\existiiifalse
  \ifexistii\toks0=\@xp{\the\toks0 \footerii}\fi 
  \global\existiifalse
  \ifexisti\else\toks0={\headeri}\fi  
  \global\existitrue
  \toks0=\@xp{\the\toks0 \item}% 
  \toks0=\@xp{\the\toks0\@jfbutmp}%
  \global\agendatoks=\@xp\@xp\@xp{\@xp\the\@xp\agendatoks\the\toks0}%
}

\renewcommand\l@subsection[2]{%
  \let\@xp\expandafter
  \let\numberline\@gobble
  \def\hyper@linkstart{\noexpand\hyper@linkstart}%
  \def\hyper@linkend{\noexpand\hyper@linkend}%
  \edef\@jfbutmp{#1}%
  \ifexistiii\toks0={\footeriii}\else\toks0={}\fi
  \global\existiiifalse
  \ifexistii\else\toks0={\headerii}\fi
  \global\existiitrue
  \toks0=\@xp{\the\toks0 \item}%
  \toks0=\@xp{\the\toks0\@jfbutmp}
  \global\agendatoks=\@xp\@xp\@xp{\@xp\the\@xp\agendatoks\the\toks0}
}

\renewcommand\l@subsubsection[2]{%
  \let\@xp\expandafter
  \let\numberline\@gobble
  \def\hyper@linkstart{\noexpand\hyper@linkstart}%
  \def\hyper@linkend{\noexpand\hyper@linkend}%
  \edef\@jfbutmp{#1}%
  \ifexistiii\toks0={}\else\toks0={\headeriii}\fi
  \global\existiiitrue
  \toks0=\@xp{\the\toks0 \item}%
  \toks0=\@xp{\the\toks0\@jfbutmp}%
  \global\agendatoks=\@xp\@xp\@xp{\@xp\the\@xp\agendatoks\the\toks0}%
}

\makeatother


% the following (from package titlesec) only influences the look of the body,
% not the table of contents
\titleformat{\section}
  {\normalfont\LARGE\bfseries\sffamily}{}{0em}{}
\titleformat{\subsection}
  {\normalfont\Large\sffamily}{}{1em}{}
\titleformat{\subsubsection}
  {\normalfont\large\ttfamily}{}{2em}{}

\begin{document}\thispagestyle{empty}

\tableofcontents

\section{First}
\kant[1]
\subsection{primo}
\kant[11]
\subsection{secondo}
\kant[12]
\subsubsection{i}
\kant[121]
\subsubsection{ii}
\kant[122]
\subsection{tertio}
\kant[13]
\subsubsection{i}
\kant[131]
\subsubsection{ii}
\kant[132]
\subsubsection{iii}
\kant[133]
\section{Second}
\kant[2]
\subsection{primo}
\kant[21]
\subsubsection{i}
\kant[111]
\subsubsection{ii}
\kant[112]
\subsubsection{iii}
\kant[113]
\subsection{secondo}
\kant[22]
\section{Third}
\kant[3]
\subsection{tertio}
\kant[33]
\section{Fourth}
\kant[4]
\subsection{quarto}
\kant[44]
\subsubsection{i}
\kant[141]
\subsubsection{ii}
\kant[142]
\subsubsection{iii}
\kant[143]

\end{document}
share|improve this answer
    
In the \toks0 lines of the code, the \noexpand before \item or \footerii can be replaced by a space. Furthermore, \toks0=\ex{\the\toks0\@jfbutmp} works because TeX expands \@jfbutmp (looking if it gives a digit). I leave \toks0=\ex\ex\ex{\ex\the\ex\toks0\@jfbutmp} as is with its many \expandafter as it is simpler to understand while reading it what it does. –  jfbu Oct 31 '12 at 10:38
    
I have in fact now edited the code to use the trick from my comment above to have less \expandafter's. Also I remove some other expansion so that the token list \agendatoks works the same way but is shorter. –  jfbu Oct 31 '12 at 10:59
    
The macros here are not compatible with having certain types of commands inside section or subsection names. Slightly different macros achieve this, still in an hyperref compatible way. But this goes a bit too far from the original question so I leave things as they stand. –  jfbu Nov 2 '12 at 23:05

I guess that this is what you want:

\documentclass{scrartcl}
\usepackage{lipsum}

\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{0}

\makeatletter
\renewcommand\tableofcontents{\@starttoc{toc}}
\renewcommand*\l@section[2]{\item #1}
\makeatother
\AtBeginDocument{\addtocontents{toc}{\protect\begin{enumerate}}}
\AtEndDocument{\addtocontents{toc}{\protect\end{enumerate}}}

\begin{document}

\tableofcontents
\section{Agenda item one}
\lipsum[4]
\section{Agenda item two}
\lipsum[4]
\section{Agenda item three}
\lipsum[4]
\section{Agenda item four}
\lipsum[4]

\end{document}

enter image description here

share|improve this answer

Here is a version that uses How keep a running list of strings and then process them one at a time to store the titles of all the \section*{}, and then this can be printed in an enumerated list at the end. So, with a document as:

\begin{document}
\section{First Non Starred Section}
\section*{First Starred section}
\section*{Second Starred section}

\section{Second Non Starred Section}
\section*{Third Starred section}
\section*{Fourth Starred section}
\end{document}

we get the following at the end of the document:

enter image description here

Notes:

  • I used the xparse package to distinguish between \section and \section* as I prefer it's syntax, but it should be possible to implement the same functionality without it.

Code:

\documentclass{article}
\usepackage{xparse}

% http://tex.stackexchange.com/questions/14393/how-keep-a-running-list-of-strings-and-then-process-them-one-at-a-time
\def\ListOfSectionTitles{}
\makeatletter
    \newcommand{\AddSectionTitle}[1]{\g@addto@macro\ListOfSectionTitles{{\item #1}}}
\makeatother

\let\OldSection\section
\RenewDocumentCommand{\section}{s m}{%
    \IfBooleanTF{#1}{%
        % This is a starred section, so store it's title
        \AddSectionTitle{#2}%
        \OldSection*{#2}%
    }{%
        \OldSection{#2}%
    }%
}

\AtEndDocument{%
    \textbf{List of Starred Sections:}
    \begin{enumerate}
        \ListOfSectionTitles
    \end{enumerate}
}%

\begin{document}
\section{First Non Starred Section}
\section*{First Starred section}
\section*{Second Starred section}

\section{Second Non Starred Section}
\section*{Third Starred section}
\section*{Fourth Starred section}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.