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.

Most or all papers have a final paragraph in the introduction that describes the sections that are present. I'd like to generate it automatically, I guess this should be possible because it is mostly like an index, but in fact I have no idea about how this could be done (therefore I can't provide a mwe, I'm very sorry for this).

My guess is that it should be possible to add a description for each section, something like:

\section{Preliminaries}
\label{sec:preliminaries}
\description{we introduce the concepts that will be relevant along the paper}

What I would like is to insert at the end of the introduction something like this:

\descriptions{}

Which should expand to:

The structure of the paper is as follows: In Section 2 we introduce the concepts that will be relevant along the paper. In Section 3 we...

This is pretty much like the table of contents (TOC) that you would find in any book, this is prose and not a table and there is one additional field, but in short it's the same. Seems feasible.

Pointers to what should I check are also welcome, I really have no idea. I don't know how those TOCs are generated either.

PD: I'd prefer not to destroy the possibility of having a regular TOC additionally to this, i.e. I'd prefer not to modify the commands for the TOC (but maybe duplicate some of them).

PD: I found this package, but I get an error (\l@paragraph undefined) http://texblog.org/2008/07/13/define-your-own-list-of/

share|improve this question
2  
I'm a fan of automation, I can't help it, this may be taking it a bit too far. Maybe I'm an addict. This still looks cool to me. –  Trylks May 29 at 14:47
1  
@egreg 's answer to tex.stackexchange.com/questions/60738/… may help you here –  Ethan Bolker May 29 at 15:01
    
thank you, this is fine, but it relies on commands for the toc that are still magic to me –  Trylks May 29 at 15:10
add comment

2 Answers 2

Use the already provided infrastructure; we use a supplementary “table of contents”, which doesn't interfere with the standard one.

Just initialize the production of this “table of contents” and add a command \l@desc that will be used for printing the entries gathered in the previous run. Of course, two runs are necessary for synchronizing.

\documentclass{article}

\makeatletter
\newcommand{\sectiondescriptions}{%
  \par
  The structure of the paper is as follows.
  \par
  \@starttoc{dsc}%
}
\newcommand{\sectiondescription}[1]{%
  \addcontentsline{dsc}{desc}{In Section \thesection\space#1}%
}
\newcommand{\l@desc}[2]{#1\par}
\makeatother

\begin{document}

\section{Introduction}

We say something about the paper.

\sectiondescriptions

\section{Preliminaries}\label{sec:preliminaries}
\sectiondescription{we introduce the concepts that will be relevant along the
  paper.}

\section{Conclusion}
\label{sec:conclusion}
\sectiondescription{we are done.}

\end{document}

enter image description here

share|improve this answer
    
I like your solution better than mine. The OP seems to want each section description in its section as well as at the beginning - easy to add that #1. –  Ethan Bolker May 29 at 23:58
    
I'm not particularly concerned with content-replication but more with an intelligent behaviour of some parts of the paper wrt to others. E.g. switching the order of two sections, which could now be as simple as switching two lines with \input{sectionfile}. –  Trylks May 30 at 13:32
    
I like this solution because it relies on commands that are already defined (and tested, and higher-level) but these commands make the text in the description clickable and that is puzzling (potentially annoying) to people reading the paper. Do you know if there is any way to avoid this? –  Trylks May 30 at 13:33
    
BTW: I have made some (really small) changes to this solution and put the code here: gist.github.com/trylks/6bbbdaff10b5dd35d676 in toclike.tex I should produce a mwe at some point. –  Trylks May 30 at 13:36
add comment

Compiling this twice does what you ask for. It's a little fragile.

Edited to use @Dan 's \InputIfFileExists but still prefer closing the file explicitly.

\documentclass{article}

\newcommand{\structure}{\InputIfFileExists{structure}{}}

\newcommand{\beginstructure}[1]{%
\newwrite\delayedtext
\immediate\openout\delayedtext=structure.tex
\immediate\write\delayedtext{#1}
}

\newcommand{\addtostructure}[1]{%
\immediate\write\delayedtext{%
In Section \arabic{section} #1}
In this section #1 
}

\newcommand{\myendstructure}{% 
\immediate\closeout\delayedtext
}

\begin{document}
\structure

\beginstructure{The structure of the paper is as follows.}

\section{Preliminaries}
\label{sec:preliminaries}
\addtostructure{we introduce the concepts that will be relevant along the
  paper.}

\section{Conclusion}
\label{sec:conclusion}
\addtostructure{we are done.}

\myendstructure
\end{document}

enter image description here

Edit: If you don't like the tex extension on the auxiliary file you can give it any extension you like, and name it with the tex source filename - for example

\immediate\openout\delayedtext=\jobname.struct
...
\newcommand{\structure}{\InputIfFileExists{\jobname.struct}{}}
share|improve this answer
    
Probably \InputIfFileExists would be better than a plain \input, so that structure.tex wouldn't have to exist already. Also, one can close the file automatically by putting the commands to do so in \AtEndDocument{}. However, latex should automatically close all open files when it terminates. –  Dan May 29 at 18:04
    
What I like less from this solution is that the contents of this "special toc" are stored in a tex file, which is confusing visually (wrt icons) when exploring the folder, copy-pasting relevant files (*.tex), etc. therefore inspired by this solution I have made some modifications. They are in fileread.tex: gist.github.com/trylks/6bbbdaff10b5dd35d676 I'll produce a mwe at some point. –  Trylks May 30 at 13:35
add comment

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.