4

In a report I have multiple chapters as separate tex files that I include by means of \input{chapter_title}. Furthermore I have a chapter 0 which deals as an introduction. The introduction shall contain a single paragraph for each chapter roughly describing what's written in the chapter. The order in which the chapters appear is not yet fixed and might change a couple of times. Since I'm a sort of lazy fellow I would like to have the short description paragraph in the actual chapter file and have the introduction chapter generate the order of the description paragraphs based on the order of the \input{chapter} calls.

Document class is scrreprt.

The description paragraphs of the chapters as they are defined in the chapter tex-files could look like this:

\<some_reference_to_current_chapter> describes...

or

In \<some_reference_to_current_chapter> ... will be explained. 

The references to the current chapter should be generated automatically so that the result is always in the order of the chapters and the chapter numbers in the description paragraphs as it is printed in the introduction chapter will always be consistent.

I assume this might possible by means of something similar to the table of contents, just not using the chapter headlines but the description paragraphs instead.

Is there an easy way to achieve this?

  • Do you need need hyperlinking as well? – user31729 Jun 12 '17 at 12:55
  • Yes, that would be nice. If it's impossible, though, I think I could also live without it. – Hendrik Wiese Jun 12 '17 at 12:57
1

You can use the tocloft package to create your own toc-like lists. Minimal example:

\documentclass[totocnumbered]{article}
\usepackage{lipsum}

\usepackage[titles]{tocloft}
\newlistof{intro}{intro}{Introductions}
\newcommand{\introduction}[1]{%
    \refstepcounter{intro}%
    \addtocontents{intro}{#1}%
    \addtocontents{intro}{}%
}

\begin{document}

\listofintro

\section{First}
\label{sec:first}
\introduction{Chapter \ref{sec:first} has the first two paragraphs of \emph{Lorem ipsum}. This is a very interesting start to this document.}
\lipsum[1-2]

\section{Second}
\label{sec:second}
\introduction{In Chapter \ref{sec:second}, we find the third and fourth paragraph.}
\lipsum[3-4]

\end{document}

enter image description here

I didn't find an easy way to have a \thischapter (or so) macro that you can use in the introductions, however using the \label and \ref pair for the chapters should be fair enough. Also, this gives you correct hyperlinks (in case you want them).

Edit 1: If you also load the package subfigure, you have to load tocloft with the option subfigure:

\usepackage[titles,subfigure]{tocloft}

Edit 2: If you want to have the introductions without the "Introductions" headline (note that you can adjust this label), you can redefine (after the call of \newlistof) the \listofintro macro like this (credits):

\makeatletter
\renewcommand\listofintro{%
    \@starttoc{intro}%
}
\makeatother

A side effect is that you furthermore don't insert a page break before.

  • For some reason I'm getting the error message ! LaTeX Error: Command \c@lofdepth already defined.Or name \end... illegal, see p.192 of the manual.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... \newcounter{lofdepth} when trying to run with \usepackage[titles]{tocloft} – Hendrik Wiese Jun 12 '17 at 13:16
  • Then there is probably a problem with one of your packages or your documentclass. What do you use? – Tiuri Jun 12 '17 at 13:19
  • The documentclass is scrreprt. The other packages are listed here, including the used options: pastebin.com/1fDqakQd I might not need all of them. The list of packages comes from a template that we use in our company. – Hendrik Wiese Jun 12 '17 at 13:26
  • I've figured it collides with package subfigure – Hendrik Wiese Jun 12 '17 at 13:33
  • I see! Just add subfigure as an option to tocloft. I'll also add that to the answer. – Tiuri Jun 12 '17 at 13:34
1

A first version without hyperlinking, the tcolorbox is just an option and can be removed.

\documentclass{book}

\usepackage[most]{tcolorbox}
\usepackage{blindtext}

\makeatletter

\newcounter{chapterdesc}


\newcommand{\l@cd}[2]{%
  \begin{tcolorbox}[enhanced jigsaw, sharp corners, colback=white!60!yellow,colframe=red!80!black]
    In \cref{#1} we will see #2
  \end{tcolorbox}
}

\newcommand{\chapterdescription}[2]{%
  \addtocontents{cd}{\protect\contentsline{cd}{#1}{#2}}
}

\newcommand{\listofchapterdescriptions}{%
  \@starttoc{cd}
}

\makeatother


\usepackage{cleveref}


\begin{document}

\listofchapterdescriptions

\chapterdescription{foochapter}{This is the first 

chapter description}
\chapter{Foo}\label{foochapter}


\chapterdescription{somechapter}{\blindtext  

\blindtext}
\chapter{Third}\label{somechapter}

\chapterdescription{foobarchapter}{This is the second chapter description}
\chapter{Second}\label{foobarchapter}




\end{document}
  • Should this also work with documentclass scrreprt? – Hendrik Wiese Jun 12 '17 at 13:28
  • @Hendrik Wiese: there's no indication of scrreprt in your question – user31729 Jun 12 '17 at 13:44
  • Yeah, sorry, my bad. I'll add the information. – Hendrik Wiese Jun 12 '17 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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