3

I am using the following code but it will create no pdf file. My Compiler report me no errors but won't create a pdf file:-( If I comment the parbox it works, but I need the parbox.

\documentclass{book}
\usepackage{titletoc}
\usepackage{lipsum}% just to generate some text

% This part changes how chapters are displayed in the Table of COntents
\titlecontents{chapter}
  [0pt]% Left margin, optional
  {}% Code insertet above
  {\bfseries}% Numbered-entryformat
  {\bfseries}% Numberless-format
  {\contentspage\vskip1.5ex} %Below code, here: add dotfill and pagenumber for entry, and some vertical space between entries

% Custom command to keep the author on the same page of chaptertitle, and above it.  
\newcommand{\chapterAndAuthor}[2]{%
 % Takes the following input
 % #1: Author
 % #2: Chaptertitle
\clearpage%
    % Minipage to keep the author and chaptertitle on same page
    \noindent\begin{minipage}{\textwidth}
        % Set the author style
        {\bfseries#1}
        % Bring the chaptertitle a bit closer to the authrotitle
        \vspace{-3\baselineskip}
        % Add an entry to the Table of Contents, with the name of the author in italics and the chapter title
        \addcontentsline{toc}{chapter}{{\normalfont\itshape #1}\vspace{1ex}\newline%
        %To make long chapter titles spanning multiple lines indent on each line, a \parbox is created. This is siimply a box holding a wrapped paragraph at a certain length. Also, we need to move the dotfill here.
        \hspace*{1em}\parbox{\textwidth}{#2 \dotfill}}
        % Print the chapter
        \chapter*{#2}
    \end{minipage}
    }

\begin{document}
\tableofcontents

\clearpage

\chapterAndAuthor{The name of the first author, The name of second author and The name of the third author}{Test Chapter One is really long, and I wouldn't really bother to read it as I am falling asleep}

\lipsum[1-20]

\chapterAndAuthor{John Doe}{Test Chapter Two}
\lipsum[1-20]

\end{document}

This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2015.5.20)  1 JUN 2016 12:39
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**book.tex -recorder
(./book.tex
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/bk10.clo
File: bk10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@chapter=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/local/texlive/2014/texmf-dist/tex/latex/titlesec/titletoc.sty
Package: titletoc 2011/12/15 v1.6 TOC entries
\ttl@leftsep=\dimen103
)
(/usr/local/texlive/2014/texmf-dist/tex/latex/lipsum/lipsum.sty
Package: lipsum 2011/04/14 v1.2 150 paragraphs of Lorem Ipsum dummy text
\c@lips@count=\count88
) (./book.aux)
\openout1 = `book.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 34.
LaTeX Font Info:    ... okay on input line 34.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 34.
LaTeX Font Info:    ... okay on input line 34.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 34.
LaTeX Font Info:    ... okay on input line 34.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 34.
LaTeX Font Info:    ... okay on input line 34.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 34.
LaTeX Font Info:    ... okay on input line 34.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 34.
LaTeX Font Info:    ... okay on input line 34.

(./book.toc)
\tf@toc=\write3
\openout3 = `book.toc'.

 [1


{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}])
! Incomplete \iffalse; all text was ignored after line 39.
<inserted text> 
                \fi 
<*> book.tex 
             -recorder
The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

! Emergency stop.
<*> book.tex -recorder

*** (job aborted, no legal \end found)


Here is how much of TeX's memory you used:
 542 strings out of 493117
 6387 string characters out of 6135433
 146497 words of memory out of 5000000
 4079 multiletter control sequences out of 15000+600000
 4554 words of font info for 17 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 23i,4n,17p,241b,123s stack positions out of 5000i,500n,10000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!
  • Compiles for me. Show the log-file. – Ulrike Fischer Jun 1 '16 at 10:35
  • Works in LiveTeX on Ubuntu 16.04. What distribution you use? – Jori Mäntysalo Jun 1 '16 at 10:36
  • I added the log.file below the code example after \end{document}. Using sublime on mac yosemite, tried it on win 7, with MiKtex 2.9 as well – mvp285286 Jun 1 '16 at 10:46
  • 2
    Breaks in tl2014 but works fine in tl2015. Use \protect\parbox{...}. Btw: "! Emergency stop." is an error. Don't rely on your editor to report all errors. – Ulrike Fischer Jun 1 '16 at 11:01
  • @UlrikeFischer maybe you should add that as an answer? Seems to have fixed the error for th OT. – Runar Jun 1 '16 at 11:33
5

You should protect commands in a \addcontentsline argument so that they don't break when are written to the toc. In your case (the other commands are robust):

\addcontentsline{toc}{chapter}{{\normalfont\itshape #1}\vspace{1ex}\newline%
\protect\hspace*{1em}\protect\parbox{\textwidth}{#2 \protect\dotfill}}

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.