-3

Below is part of my code.

\documentclass[11pt,table,a5paper]{article}
\usepackage{array,ragged2e}
\usepackage{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[top=2cm, bottom=2cm, outer=1cm, inner=2.1cm,twoside, headsep=16pt]{geometry}
\usepackage{ifthen} 
\usepackage{wrapfig}
\usepackage{comment}
\usepackage{parskip}
\usepackage{framed}
\usepackage{sidecap}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{lipsum} 
\usepackage{url}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{transparent}
\usepackage{hyphenat}
\usepackage{bm}
\newcommand{\+}{\discretionary{\mbox{${\bm\cdot}\mkern-1mu$}}{}{}}
\usepackage{microtype}
\usepackage{xstring}
\usepackage{forloop}
\usepackage{collcell}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{varwidth} 
\usepackage{textcomp}
\usepackage{enumitem}
\usepackage[T1,T2A]{fontenc}
\usepackage{CJKutf8}
\usepackage{alltt}
\usepackage{caption}
\captionsetup{skip=5pt,font=footnotesize}
\usepackage[labelformat=empty]{caption}
\usepackage{needspace}
\usepackage{setspace}   
\singlespacing
\raggedbottom
\usepackage{keyval}% http://ctan.org/pkg/keyval
\makeatletter
\newlength{\mylist@beforeskip}
\newlength{\mylist@afterskip}

\define@key{mylist}{beforeskip}{\setlength{\mylist@beforeskip}{#1}}
\define@key{mylist}{afterskip}{\setlength{\mylist@afterskip}{#1}}
\newenvironment{mylist}[1][,]
 {\setkeys{mylist}{beforeskip=10pt,afterskip=10pt,#1}%
\par\vspace*{\mylist@beforeskip}%
\begin{itemize}}
{\end{itemize}%
\vspace*{\mylist@afterskip}}
\makeatother
\usepackage{etoolbox,graphicx}% http://ctan.org/pkg/{etoolbox,graphicx}
\newcommand{\addstufftotoc}[2][toc]{% \addimagetotoc[<toc>]{<stuff>}
\addtocontents{#1}{#2}}
\makeatletter
\patchcmd{\l@section}% <cmd>
{\begingroup}% <search>
{\begingroup\normalfont\Large\bfseries}% <replace>
{}{}% <success><failure>
\makeatother


\usepackage{etoolbox}
\newcounter{cnt}
\newcommand\textlist{}
\newcommand\settext[2]{%
\csdef{text#1}{#2}}
\newcommand\addtext[1]{%
\stepcounter{cnt}%
\csdef{text\thecnt}{#1}}
\newcommand\gettext[1]{%
\csuse{text#1}}
\newcounter{colnum}
\newcommand\maketabularrow[1]{%
\setcounter{colnum}{0}%
\whileboolexpr
{ test {\ifnumcomp{\value{colnum}}{<}{#1}} }%
 {&\stepcounter{colnum}\thecolnum}
}
%   
\def\hlinewd#1{%
\noalign{\ifnum0=`}\fi\hrule \@height #1 %
\futurelet\reserved@a\@xhline} 
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\begin{document}
\tableofcontents
\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] 
\end{mdframed} 
\small 
\leavevmode 
\newline 
\leavevmode 
\newline 
\scriptsize  
\addcontentsline{toc}{section}{\protect\numberline{}AAA} 
\addstufftotoc{\nobreak\smallskip\protect\includegraphics[trim=0.6cm 4.5cm 0cm 1cm, clip=true,width=1.0\linewidth]{./tmp/AAA.pdf}\par} 
\leavevmode 
\newline 
\\ 
} 
\newpage 

\end{document}linecolor=goldenpoppy

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
6

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>}
  \addtocontents{#1}{%
    \unexpanded{\unexpanded{\nobreak\smallskip#2\par\medskip}}%
  }%
}

and use it as

\addstufftotoc{\includegraphics[trim=0.6cm 4.5cm 0cm 1cm,
  clip=true,width=1.0\linewidth]{./tmp/AAA.pdf}}

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.