4

I really like the ornaments that this block of code makes for me:

\usepackage{eso-pic}
\makeatletter
\AddToShipoutPicture{%
\begingroup
\setlength{\@tempdima}{2mm}%
\setlength{\@tempdimb}{\paperwidth-\@tempdima-2cm}%
\setlength{\@tempdimc}{\paperheight-\@tempdima}%
\put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimc}){%
\pgfornament[anchor=north west,width=2cm]{63}}
\put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdima}){%
\pgfornament[anchor=south west,width=2cm,symmetry=h]{63}}
\put(\LenToUnit{\@tempdimb},\LenToUnit{\@tempdimc}){%
\pgfornament[anchor=north east,width=2cm,symmetry=v]{63}}
\put(\LenToUnit{\@tempdimb},\LenToUnit{\@tempdima}){%
\pgfornament[anchor=south east,width=2cm,symmetry=c]{63}}
\endgroup
}
\makeatother

It comes from page 11 of pgfornament and it makes all four corners have these pretty ornaments that you see in the linked PDF.

Last year I used it myself for several of my documents and achieved identical results as what you see in the linked PDF, but this year it seems to be breaking with no informative error message. Instead of all four corners getting these nice ornaments, now only the two left corners get the ornaments and the typesetting process halts with this error message for every decorated page:

Missing number, treated as zero.
<to be read again>
\relax

I think I must have upgraded one or more packages since I last used this code successfully and that's probably why it's breaking, but I'm mystified by the error message and clueless as to how to fix the problem. I've confirmed (by commenting out the block of code) that this code is definitely what is throwing the error message, and even though I can continue compiling with "s", the PDF output no longer has all 4 corners decorated, so I'd like to fix it.

Any suggestions on how to fix this?

  • 1
    Are you loading the calc package? Otherwise, you'll receive the error you mention. – Gonzalo Medina Jul 16 '14 at 14:55
  • 1
    Please add a full MWE which results in this error! – LaRiFaRi Jul 16 '14 at 14:55
7

Since you are performing some additions/subtractions with lengths, you need to either load the calc package:

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the exmaple
\usepackage{pgfornament}
\usepackage{eso-pic}
\usepackage{calc}

\makeatletter
\AddToShipoutPicture{%
\begingroup
\setlength{\@tempdima}{2mm}%
\setlength{\@tempdimb}{\paperwidth-\@tempdima-2cm}%
\setlength{\@tempdimc}{\paperheight-\@tempdima}%
\put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimc}){%
\pgfornament[anchor=north west,width=2cm]{63}}
\put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdima}){%
\pgfornament[anchor=south west,width=2cm,symmetry=h]{63}}
\put(\LenToUnit{\@tempdimb},\LenToUnit{\@tempdimc}){%
\pgfornament[anchor=north east,width=2cm,symmetry=v]{63}}
\put(\LenToUnit{\@tempdimb},\LenToUnit{\@tempdima}){%
\pgfornament[anchor=south east,width=2cm,symmetry=c]{63}}
\endgroup
}
\makeatother

\begin{document}

Test

\end{document}

or to use \dimexpr:

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the exmaple
\usepackage{pgfornament}
\usepackage{eso-pic}

\makeatletter
\AddToShipoutPicture{%
\begingroup
\setlength{\@tempdima}{2mm}%
\setlength{\@tempdimb}{\dimexpr\paperwidth-\@tempdima-2cm\relax}%
\setlength{\@tempdimc}{\dimexpr\paperheight-\@tempdima\relax}%
\put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimc}){%
\pgfornament[anchor=north west,width=2cm]{63}}
\put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdima}){%
\pgfornament[anchor=south west,width=2cm,symmetry=h]{63}}
\put(\LenToUnit{\@tempdimb},\LenToUnit{\@tempdimc}){%
\pgfornament[anchor=north east,width=2cm,symmetry=v]{63}}
\put(\LenToUnit{\@tempdimb},\LenToUnit{\@tempdima}){%
\pgfornament[anchor=south east,width=2cm,symmetry=c]{63}}
\endgroup
}
\makeatother

\begin{document}

Test

\end{document}

The result in both cases:

enter image description here

  • That fixed it. That's so interesting! Curious: what changed in the last 6-12 months for this code to require the calc package? I definitely was not using it before, and it worked fine then. Thanks for your help! – TeXnewbie Jul 16 '14 at 22:21
  • @TeXnewbie The code has always required one of my two solutions. Perhaps you were loading some package which internally loaded calc and then you stop loading it? – Gonzalo Medina Jul 16 '14 at 23:30

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.