If I process the following MWE with pdflatex (TeXLive 2012, Linux)

\pdfinfo{/Title (Some text \textbf{This macro causes problems})}
Hello world

I get an error from ../texmf-dist/tex/context/base/supp-pdf.mkii. That seems to be a ConTeXt file. The error is

! TeX capacity exceeded, sorry [input stack size=5000].
\@@mpstopdf@@unprotect ... \@@mpstopdf@@unprotect 
                           \unprotect \let \@@mpstopd...
l.34     \def\unprotect

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

It also happens if I load xcolor, but not if I load graphicx or any other package I have tried. While it is not specific to \textbf, I don't get the problem with \mymacro.

What is going on?


It's not specific to \textbf but \pdfinfo has to put a plain text string into the pdf data so most TeX commands will cause problems. You just want

\pdfinfo{/Title (Some text This macro causes problems)}

The graphics package loads that file to support loading metapost files, as Hans wrote it to work with any TeX flavour and there seemed no need to re-write it just because it had a context rather than latex heritage. It is unrelated to the error you get on your example. color and graphics share the same .def files so loading either will cause the file to be loaded.

  • I do not get the error if I load graphics or graphicx, but I do with color and xcolor. The fully expandable \mymacro doesn't cause problems. In the bigger picture I am setting /Title with \@title so eliminating the macros isn't trivial. The error message is about the redefined \unprotect, so it definitely seems related to supp-pdf.mkii. – StrongBad Mar 11 '13 at 19:33
  • 6
    \textbf is not fully expandable, inside LaTeX's protected expansion contexts (writing to the .toc file, ...) it produces itself (more or less). However \pdfinfo performs a hard expansion that breaks the assignments inside \textbf. Thus instead of defining \@reserveda, the previous meaning of \@reserveda is used (adding supp-pdf.mkii to the file list). To get \textbf into the title, you would have to use something like \string\\textbf (PDF strings require backslash doubling). But I don't know a PDF viewer that know about LaTeX or TeX. See also package hyperref. – Heiko Oberdiek Mar 11 '13 at 19:46

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.