4

There is an arithmetic or interface problem with the package pdfpages. Let us include a scan from a book:

% !TEX TS-program = pdflatex

\documentclass[11pt]{book}  
\usepackage{pdfpages}

\begin{document}
\includepdf[pages = 1, scale = 0.10, offset = 0mm 0mm, angle =  0.90 ]{scan1}
\includepdf[pages = 1, scale = 0.56, offset = 0mm 0mm, angle = -0.9  ]{scan2}
\end{document}

The correct angle to include scan2 is -0.9.

— If the angle of the first include is different of 0.9 as a string (by example, 0.90), the inclusion of scan2 is OK (the lines do not belong to the scan) :

enter image description here

— But if the angle of the first include is 0.90 as a string, then the orientation of scan2 is wrong :

enter image description here

  • Interesting. pdfpages is not at fault, the problem exists also with graphicx and looks like a tex core problem. \number -0.9 \relax outputs 0.9 and so the second image reuses the angle calculation of the first. – Ulrike Fischer Aug 17 '16 at 12:19
  • After a discussion in the chat I think the problem is with trig.sty. – Ulrike Fischer Aug 17 '16 at 12:32
3

The problem is that trig uses \number#1 to force the decimal expansion of the value (which might be a register or chardef token) but \number-0.9 is 0.9 as \number only sees the integer part and 0=-0.

You can force the correct interpretation of sin as below (or more simply just add (say) 360 to the value so it isn't a value between 0 and -1 which is the only range that fails)

\documentclass{article}
\usepackage{graphicx}
\makeatletter
\def\UseSin#1{\csname sin(\ifdim#1\p@<\z@-\number-#1\else\number#1\fi)\endcsname}
\def\UseCos#1{\csname cos(\ifdim#1\p@<\z@-\number-#1\else\number#1\fi)\endcsname}


\CalculateSin{0.9}
\CalculateCos{0.9}
\typeout{A: \UseSin{0.9},\UseCos{0.9}}
\expandafter\xdef\csname sin(-0.9)\endcsname{-\UseSin{0.9}}
\expandafter\xdef\csname cos(-0.9)\endcsname{\UseCos{0.9}}
\expandafter\xdef\csname sin(-0.91)\endcsname{-\UseSin{0.91}}
\expandafter\xdef\csname cos(-0.91)\endcsname{\UseCos{0.91}}

\typeout{B: \UseSin{-0.9},\UseCos{-0.9}}


\begin{document}

\includegraphics[scale = 0.50, angle =  0.9 ]{example-image-a}
\includegraphics[scale = 0.50, angle = -0.9 ]{example-image-b}

\includegraphics[scale = 0.50, angle =  0.910 ]{example-image-a}
\includegraphics[scale = 0.50, angle = -0.91 ]{example-image-b}

\end{document}

I'll see if I can think of a better fix to add to trig...

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.