Skip to content

Instantly share code, notes, and snippets.

@koppor
Last active February 8, 2017 08:32
Show Gist options
  • Save koppor/16659c4ef9ab7d088b2bc6eef420762e to your computer and use it in GitHub Desktop.
Save koppor/16659c4ef9ab7d088b2bc6eef420762e to your computer and use it in GitHub Desktop.
Prevent division by zero at pax
\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{pax}
\makeatletter
\def\PAX@viewport#1 #2 #3 #4\\{%
\PAX@defaultbp\PAX@vllx{#1}%
\PAX@defaultbp\PAX@vlly{#2}%
\PAX@defaultbp\PAX@vurx{#3}%
\PAX@defaultbp\PAX@vury{#4}%
\edef\PAX@page@llx{\the\dimexpr\PAX@page@llx+\PAX@vllx\relax}%
\edef\PAX@page@lly{\the\dimexpr\PAX@page@lly+\PAX@vlly\relax}%
\edef\PAX@page@urx{\the\dimexpr\PAX@page@llx+\PAX@vurx\relax}% FIXED
\edef\PAX@page@ury{\the\dimexpr\PAX@page@lly+\PAX@vury\relax}%
}
\makeatother
\begin{document}
\includegraphics[page=1, viewport=0 0 21cm 23.628cm]{pax-include.pdf}
\end{document}
\documentclass{scrartcl}
\usepackage{hyperref}
\begin{document}
\section{Section}
\label{sec}
This is Section~\ref{sec}.
\end{document}
@koppor
Copy link
Author

koppor commented Feb 8, 2017

When including a pdf with viewport, pdflatex gives following error:

! Package graphics Error: Division by 0.

One can reproduce the issue with following commands:

pdflatex pax-include
pdflatex pax-include
perl C:\MiKTeX\scripts\pax\pdfannotextractor.pl pax-include
pdflatex pax-demo

When using the above fix, the example compiles fine.

Thank to Heiko Oberdiek for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment