6

I keep adding a class of sentences in different areas of my tex:

\section{...}
... 
sentence1
... 
\subsection{...}
... 
sentence2
... 
\section{...}
... 
sentence3
... 

I would like to make a add mechanisms, label all the sentences and later summarize them in a place by listallthesentences:

\section{...}
... 
\add{sentence1}
... 
\subsection{...}
... 
\add{sentence2}
... 
\section{...}
... 
\add{sentence3}
... 
\section{summary}
\listallthesentences

In the summary, it will be better, if all the sentences are repeated and have a reference pointed to their initial place.

Does anyone know how to realize this?

lockstep
  • 250,273
SoftTimur
  • 19,767
  • This is too vague; what would you list in the "List of all sentences"? – egreg Oct 17 '12 at 09:37
  • Just repeat the sentences which are labelled with add, and have a reference pointed to their initial place... – SoftTimur Oct 17 '12 at 09:38
  • 1
    Use the package tocloft, see also http://tex.stackexchange.com/questions/61086/how-to-create-my-own-list-of-things. – bodo Oct 17 '12 at 11:12
  • In my answer below I provided a solution for generating the list; it's not clear, however, what you mean with "labelled sentences". Could you please ellaborate a little more about this labelling? – Gonzalo Medina Oct 17 '12 at 13:09

1 Answers1

7

You can use \@starttoc to generate a list similar to the ToC, Lof or LoT (it's not clear from the description, however, what "labelled sentence" means):

\documentclass{article}
\usepackage{hyperref}

\makeatletter
\newcommand\listofsentences{\@starttoc{los}}
\newcommand\addsentence[1]{%
\par\csname phantomsection\endcsname\addcontentsline{los}{section}{#1}#1\par}
\makeatother

\begin{document}

\section{Test Section One}
\addsentence{This is a test sentence.}
\section{Test Section Two}
\addsentence{This is another test sentence.}

\section{Summary}
\listofsentences

\end{document}

enter image description here

A variant (requested in a comment) without page numbers and with normal font for the entries in the new list:

\documentclass{article}
\usepackage{hyperref}

\makeatletter
\newcounter{sentence}
\newcommand\listofsentences{\@starttoc{los}}
\newcommand\addsentence[1]{%
\stepcounter{sentence}%
\par\csname phantomsection\endcsname\addcontentsline{los}{sentence}{#1}#1\par}
\newcommand\l@sentence[2]{\par\noindent#1}
\makeatother

\begin{document}

\section{Test Section One}
\addsentence{This is a test sentence.}
\section{Test Section Two}
\addsentence{This is another test sentence.}

\section{Summary}
\listofsentences

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Thanks for your comment, it is quite what I need... By the way, in the summary, I don't want to show the page of the sentences, also I don't want to make them bold, could you adjust your response? – SoftTimur Oct 17 '12 at 13:58
  • @SoftTimur sure! I've updated my answer. Is it something like that what you need? – Gonzalo Medina Oct 17 '12 at 17:06