Discussion:
[XeTeX] Conflict among XeLaTeX, LaTeX.mk, and pdfpages
m***@ansuz.sooke.bc.ca
2018-01-01 23:22:12 UTC
Permalink
I've run into a problem when using all three of XeLaTeX, LaTeX.mk, and
pdfpages, in their current versions from the latest TeXLive. It appears
that in order to determine file dependencies, LaTeX.mk runs the TeX engine
with the texdepends package (which is part of LaTeX.mk) wedged into the
input file; then texdepends intercepts a bunch of internal macros used by
various graphics packages including indirectly by pdfpages, and the result
is a failure with "arithmetic overflow" when trying to include PDF files.

All three elements seem to be necessary: it doesn't happen with other TeX
engines I've tried; when invoking XeLaTeX manually instead of through
LaTeX.mk; nor without using pdfpages. However, I can also reproduce the
problem by loading texdepends in my .tex file (with \RequirePackage - it
must be loaded before \documentclass and \usepackage cannot be used then)
and running xelatex from the command line instead of through make.

The relevant messages in the log file when it fails look like:

Package texdepends Warning: No 'testa.xbb' file
(texdepends) using 1 for graphic dimensions on input line 31.

File: testa.pdf Graphic file (type pdf)
<use testa.pdf, page 1>
! Arithmetic overflow.
<recently read> \***@Acount

l.31 \includepdf[pages=-]{testa.pdf}

Any thoughts on how this might be fixable?
--
Matthew Skala
***@ansuz.sooke.bc.ca People before principles.
http://ansuz.sooke.bc.ca/
David Carlisle
2018-01-02 00:41:12 UTC
Permalink
(apparently) you need to run

extractbb testa.pdf

after processing testa.tex and before testb.tex

not sure if pdfpages should not require this but in any case the issue
seems to be at the macro layer not
in the xetex or xdvipdfmx binaries.

David
Post by m***@ansuz.sooke.bc.ca
I've run into a problem when using all three of XeLaTeX, LaTeX.mk, and
pdfpages, in their current versions from the latest TeXLive. It appears
that in order to determine file dependencies, LaTeX.mk runs the TeX engine
with the texdepends package (which is part of LaTeX.mk) wedged into the
input file; then texdepends intercepts a bunch of internal macros used by
various graphics packages including indirectly by pdfpages, and the result
is a failure with "arithmetic overflow" when trying to include PDF files.
All three elements seem to be necessary: it doesn't happen with other TeX
engines I've tried; when invoking XeLaTeX manually instead of through
LaTeX.mk; nor without using pdfpages. However, I can also reproduce the
problem by loading texdepends in my .tex file (with \RequirePackage - it
must be loaded before \documentclass and \usepackage cannot be used then)
and running xelatex from the command line instead of through make.
Package texdepends Warning: No 'testa.xbb' file
(texdepends) using 1 for graphic dimensions on input line 31.
File: testa.pdf Graphic file (type pdf)
<use testa.pdf, page 1>
! Arithmetic overflow.
l.31 \includepdf[pages=-]{testa.pdf}
Any thoughts on how this might be fixable?
--
Matthew Skala
http://ansuz.sooke.bc.ca/
--------------------------------------------------
http://tug.org/mailman/listinfo/xetex
--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/listinfo/xetex
Andreas Matthias
2018-01-11 17:41:20 UTC
Permalink
Post by David Carlisle
(apparently) you need to run
extractbb testa.pdf
after processing testa.tex and before testb.tex
Seems like texdepends insists on using extractbb which is very unfortunate since
graphicx.sty and xetex (xdvipdfmx) don't need it at all.

Using extractbb has one big drawback: It extracts the bounding box of only
/one/ page. By default the fist page, or any other page by using the -p
option. Anyway the xbb-file contains the bounding box of only /one/ page and
this bounding box will be used for /all/ pages. If your PDF has varying page
dimensions, extractbb will wreak havoc.
Post by David Carlisle
not sure if pdfpages should not require this but in any case the issue
seems to be at the macro layer not
in the xetex or xdvipdfmx binaries.
If an xbb-file is missing texdepends will set the page dimensions to 1pt x 1pt.
While this causes an arithmetic overflow with pdfpages, the situation is not much
better with pure graphicx which does not produce any errors but is tricked into
using wrong page dimensions.

Running the following example with and without an xbb-file reveals the problem.


\RequirePackage{texdepends}
\documentclass[a4paper]{article}
\usepackage{graphicx}

\begin{document}
\fbox{%
\includegraphics[scale=.3]{dummy.pdf}}
\end{document}


For me this seems to be a bug in texdepends.

Andreas



--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/listinfo/xetex

Ulrike Fischer
2018-01-02 14:21:05 UTC
Permalink
Am Mon, 1 Jan 2018 17:22:12 -0600 (CST) schrieb
Post by m***@ansuz.sooke.bc.ca
I've run into a problem when using all three of XeLaTeX, LaTeX.mk, and
pdfpages, in their current versions from the latest TeXLive. It appears
that in order to determine file dependencies, LaTeX.mk runs the TeX engine
with the texdepends package (which is part of LaTeX.mk) wedged into the
input file; then texdepends intercepts a bunch of internal macros used by
various graphics packages including indirectly by pdfpages, and the result
is a failure with "arithmetic overflow" when trying to include PDF files.
texdepends gets the test for the graphic existence wrong for xetex,
it assumes that the graphic is not there and set its size to 1pt
which then confuses pdfpages. It also gives errors if you set the
width of a graphic. This here could work (but I'm not sure that it
covers all cases):

\RequirePackage{texdepends}
\makeatletter
%
\def\***@Gread@pdf#1{%
\IfFileExists{\ifxetex \***@base\***@ext \else #1\fi}{% changed
%\PackageWarning{texdepends}{Gread File '#1' exists}%
\***@orig@***@pdf{#1}%
}{%
\PackageWarning{texdepends}{No '#1' file \MessageBreak
using 1 for graphic dimensions}%
\setbox\@tempboxa\hbox{\relax}%
\def\***@llx{1}\let\***@lly\***@llx
\***@defaultbp\***@urx{\wd\@tempboxa}%
\***@defaultbp\***@ury{\ht\@tempboxa}%
}%
}%

\makeatother
\documentclass{article}

\usepackage{graphicx,pdfpages}

\begin{document}

\includegraphics[width=5cm]{example-image.pdf}

\includepdf{example-image}

\end{document}
--
Ulrike Fischer
http://www.troubleshooting-tex.de/



--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/listinfo/xetex
Loading...