Below is part of my code.

\usepackage[top=2cm, bottom=2cm, outer=1cm, inner=2.1cm,twoside, headsep=16pt]{geometry}
\usepackage{keyval}% http://ctan.org/pkg/keyval

\usepackage{etoolbox,graphicx}% http://ctan.org/pkg/{etoolbox,graphicx}
\newcommand{\addstufftotoc}[2][toc]{% \addimagetotoc[<toc>]{<stuff>}
\patchcmd{\l@section}% <cmd>
{\begingroup}% <search>
{\begingroup\normalfont\Large\bfseries}% <replace>
{}{}% <success><failure>

{ test {\ifnumcomp{\value{colnum}}{<}{#1}} }%
\noalign{\ifnum0=`}\fi\hrule \@height #1 %
\begin{mdframed}[roundcorner=0pt,leftmargin=0, rightmargin=0, linecolor=gray,outerlinewidth=.1, innerleftmargin=0, innerrightmargin=0, innertopmargin=0,innerbottommargin=0, everyline = true, splittopskip=.6cm, splitbottomskip=.3cm] 
\addstufftotoc{\nobreak\smallskip\protect\includegraphics[trim=0.6cm 4.5cm 0cm 1cm, clip=true,width=1.0\linewidth]{./tmp/AAA.pdf}\par} 


I got this error message.

Underfull \hbox (badness 10000) in paragraph at lines 295--307

Underfull \vbox (badness 10000) detected at line 323
! TeX capacity exceeded, sorry [input stack size=30000].
\par ->\@restorepar 
                \everypar {}\par \@endpefalse 
l.329 ..../tmp/image.pdf}\par}

!  ==> Fatal error occurred, no output PDF file produced!

I found many replies for the similar question but none of the answer solve my pblm.

  • 7
    You have posted 37 questions so you should know that providing a minimal working example (MWE) increases your changes of getting an answer. – user10274 Mar 26 '13 at 6:58
  • Yes, I know but pblm is with my large chunk of code. I could not figure out why this pblm is. I attempted to copy a part of it but that works fine. – manish Mar 26 '13 at 7:06
  • 5
    @user15662 Although everyone faces the same kind problems while creating MWE and debugging LaTeX code. Building Up and Hacking Down are two valid approaches. – texenthusiast Mar 26 '13 at 7:38
  • 8
    @user15662 you need to take the posted code and remove all packages that are not needed. That is if you can make the error without that package, remove it. – David Carlisle Mar 26 '13 at 10:00
  • 2
    @DavidCarlisle I couldn't give you more than +1. – user10274 Mar 26 '13 at 10:45

The table of contents is typeset as a list, where \par has not its primitive meaning.

Change the definition of \addstufftotoc into

\newcommand{\addstufftotoc}[2][toc]{% \addimagetotoc[<toc>]{<stuff>}

and use it as

\addstufftotoc{\includegraphics[trim=0.6cm 4.5cm 0cm 1cm,

which saves you from the burden of adding fixed formatting instructions in \addstufftotoc.

  • Why do we need two \unexpanded here? – cjorssen Mar 26 '13 at 14:10
  • 1
    @cjorssen Because \addtocontents writes to the .aux file and then the entry is written to the .toc file at the end of the job, when the .aux file is closed and read in. – egreg Mar 26 '13 at 14:49

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.