没有创建 pdf 文件,编译器没有报告错误

没有创建 pdf 文件,编译器没有报告错误

我正在使用以下代码,但它不会创建 pdf 文件。我的编译器没有报告任何错误,但不会创建 pdf 文件:-( 如果我注释 parbox,它会起作用,但我需要 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!

答案1

您应该保护\addcontentsline参数中的命令,以便它们在写入目录时不会中断。就您的情况而言(其他命令很强大):

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

相关内容