5

Edited. Truly MWE at the bottom of this post.

I am having troubles generating the identical PDF outputs from the following Asymptote source code:

size(0, 40mm);
draw(unitsquare);
label("$1$", (0.5, 0.5), W + E);

using engines pdflatex and xelatex (compiling it with -f pdf -tex pdflatex / -f pdf -tex xelatex).

The intermediate source code becomes

\documentclass[12pt]{article}
\usepackage{ifluatex}\ifluatex
\ifx\pdfpagewidth\undefined\let\pdfpagewidth\paperwidth\fi
\ifx\pdfpageheight\undefined\let\pdfpageheight\paperheight\fi\else
\let\paperwidthsave\paperwidth\let\paperwidth\undefined
\usepackage{graphicx}
\let\paperwidth\paperwidthsave\fi
\usepackage{ifluatex}\ifluatex
\ifx\pdfpagewidth\undefined\let\pdfpagewidth\paperwidth\fi
\ifx\pdfpageheight\undefined\let\pdfpageheight\paperheight\fi\else
\let\paperwidthsave\paperwidth\let\paperwidth\undefined
\usepackage{graphicx}
\let\paperwidth\paperwidthsave\fi
\newbox\ASYbox
\newdimen\ASYdimen
\def\ASYprefix{}
\long\def\ASYbase#1#2{\leavevmode\setbox\ASYbox=\hbox{#1}%\ASYdimen=\ht\ASYbox%
\setbox\ASYbox=\hbox{#2}\lower\ASYdimen\box\ASYbox}
\long\def\ASYaligned(#1,#2)(#3,#4)#5#6#7{\leavevmode%
\setbox\ASYbox=\hbox{#7}%
\setbox\ASYbox\hbox{\ASYdimen=\ht\ASYbox%
\advance\ASYdimen by\dp\ASYbox\kern#3\wd\ASYbox\raise#4\ASYdimen\box\ASYbox}%
\setbox\ASYbox=\hbox{#5\wd\ASYbox 0pt\dp\ASYbox 0pt\ht\ASYbox 0pt\box\ASYbox#6}%
\hbox to 0pt{\kern#1pt\raise#2pt\box\ASYbox\hss}}%
\long\def\ASYalignT(#1,#2)(#3,#4)#5#6{%
\ASYaligned(#1,#2)(#3,#4){%
\special{pdf:literal q #5 0 0 cm}%
}{%
\special{pdf:literal Q}%
}{#6}}
\long\def\ASYalign(#1,#2)(#3,#4)#5{\ASYaligned(#1,#2)(#3,#4){}{}{#5}}
\def\ASYraw#1{#1}
\usepackage{graphicx}
\usepackage{color}
\pdfpagewidth=113.385827bp
\ifx\pdfhorigin\undefined
\hoffset=-1in
\voffset=-1in
\pdfpageheight=113.385827bp
\else
\pdfhorigin=0bp
\pdfvorigin=0bp
\pdfpageheight=113.385827bp
\fi
\usepackage{everypage}%
\setlength{\unitlength}{1pt}%
\pagestyle{empty}
\textheight=131.385827bp
\textwidth=131.385827bp
\parindent=0pt
\oddsidemargin=0pt
\evensidemargin=\oddsidemargin
\headheight=0pt
\headsep=0pt
\topmargin=0pt
\topskip=0pt
\begin{document}
\makeatletter%
\let\ASYencoding\f@encoding%
\let\ASYfamily\f@family%
\let\ASYseries\f@series%
\let\ASYshape\f@shape%
\makeatother%
{\catcode`"=12%
\includegraphics{test_0}%
}%
\kern -113.811024pt%
\definecolor{ASYcolor}{gray}{0.000000}\color{ASYcolor}%
\fontsize{12.000000}{14.400000}\selectfont%
\usefont{\ASYencoding}{\ASYfamily}{\ASYseries}{\ASYshape}%
\ASYalign(56.905512,56.905512)(-0.500000,-0.500000){$1$}%
\end{document}

Compiling it with pdflatex I get the following:

enter image description here

but compiling it with xelatex both the square and the label become misplaced - the square vertically, the label both horizontally and vertically:

enter image description here

Log (MiKTeX):

This is XeTeX, Version 3.14159265-2.6-0.999992 (MiKTeX 20.6.29) (preloaded format=xelatex 2020.7.15)  3 AUG 2020 02:14
entering extended mode
**./xelatex_test_.tex
(xelatex_test_.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-06-18>
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\article.cls
"
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\size12.clo"
File: size12.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
)
\c@part=\count163
\c@section=\count164
\c@subsection=\count165
\c@subsubsection=\count166
\c@paragraph=\count167
\c@subparagraph=\count168
\c@figure=\count169
\c@table=\count170
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen134
)
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\ifluatex
.sty"
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\iftex.st
y"
Package: iftex 2020/03/06 v1.0d TeX engine tests
))
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\graphic
x.sty"
Package: graphicx 2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR)

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\keyval.
sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks15
)
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\graphic
s.sty"
Package: graphics 2019/11/30 v1.4a Standard LaTeX Graphics (DPC,SPQR)

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\trig.st
y"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-cfg\gra
phics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: xetex.def on input line 105.

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-def\xet
ex.def"
File: xetex.def 2017/06/24 v5.0h Graphics/color driver for xetex
))
\Gin@req@height=\dimen135
\Gin@req@width=\dimen136
)
\ASYbox=\box45
\ASYdimen=\dimen137

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\color.s
ty"
Package: color 2019/11/23 v1.2a Standard LaTeX Color (DPC)

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-cfg\col
or.cfg"
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: xetex.def on input line 147.
)
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/everypage\everyp
age.sty"
Package: everypage 2007/06/20 1.1 Hooks to run on every page
)
("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/l3backend\l3back
end-xdvipdfmx.def"
File: l3backend-xdvipdfmx.def 2020-06-29 L3 backend support: xdvipdfmx
\g__graphics_track_int=\count171
\l__pdf_internal_box=\box46
\g__pdf_backend_object_int=\count172
\g__pdf_backend_annotation_int=\count173
) (xelatex_test_.aux)
\openout1 = `xelatex_test_.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 57.
LaTeX Font Info:    Trying to load font information for TS1+cmr on input line 5
7.

("C:\Users\user\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\ts1cmr.fd"
File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions
)
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for TU/lmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
File: test_0.pdf Graphic file (type pdf)
<use test_0.pdf>
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <12> on input line 71.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <8> on input line 71.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <6> on input line 71.
[1

] (xelatex_test_.aux) ) 
Here is how much of TeX's memory you used:
 951 strings out of 414039
 14533 string characters out of 2892337
 251271 words of memory out of 3000000
 18651 multiletter control sequences out of 15000+200000
 535082 words of font info for 34 fonts, out of 3000000 for 9000
 1348 hyphenation exceptions out of 8191
 30i,5n,25p,225b,104s stack positions out of 5000i,500n,10000p,200000b,50000s

Output written on xelatex_test_.pdf (1 page).

Apparently, there are no problems within TeX Live but I am using MiKTeX.

Log (TeX Live):

This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020/W32TeX) (preloaded format=xelatex 2020.4.18)  6 AUG 2020 23:15
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**xelatex_test_.tex
(./xelatex_test_.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-04-06>
(c:/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(c:/texlive/2020/texmf-dist/tex/latex/base/size12.clo
File: size12.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
)
\c@part=\count163
\c@section=\count164
\c@subsection=\count165
\c@subsubsection=\count166
\c@paragraph=\count167
\c@subparagraph=\count168
\c@figure=\count169
\c@table=\count170
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen134
)
(c:/texlive/2020/texmf-dist/tex/generic/iftex/ifluatex.sty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.

(c:/texlive/2020/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2020/03/06 v1.0d TeX engine tests
))
(c:/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR)

(c:/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks15
)
(c:/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2019/11/30 v1.4a Standard LaTeX Graphics (DPC,SPQR)

(c:/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
(c:/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: xetex.def on input line 105.

(c:/texlive/2020/texmf-dist/tex/latex/graphics-def/xetex.def
File: xetex.def 2017/06/24 v5.0h Graphics/color driver for xetex
))
\Gin@req@height=\dimen135
\Gin@req@width=\dimen136
)
\ASYbox=\box45
\ASYdimen=\dimen137

(c:/texlive/2020/texmf-dist/tex/latex/graphics/color.sty
Package: color 2019/11/23 v1.2a Standard LaTeX Color (DPC)

(c:/texlive/2020/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: xetex.def on input line 147.
)
(c:/texlive/2020/texmf-dist/tex/latex/everypage/everypage.sty
Package: everypage 2007/06/20 1.1 Hooks to run on every page
)
(c:/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def
File: l3backend-xdvipdfmx.def 2020-03-12 L3 backend support: xdvipdfmx
\g__graphics_track_int=\count171
\l__pdf_internal_box=\box46
\g__pdf_backend_object_int=\count172
\g__pdf_backend_annotation_int=\count173
)
(./xelatex_test_.aux)
\openout1 = `xelatex_test_.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 57.
LaTeX Font Info:    Trying to load font information for TS1+cmr on input line 5
7.
 (c:/texlive/2020/texmf-dist/tex/latex/base/ts1cmr.fd
File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions
)
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for TU/lmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 57.
LaTeX Font Info:    ... okay on input line 57.
File: test_0.pdf Graphic file (type pdf)
<use test_0.pdf>
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <12> on input line 71.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <8> on input line 71.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <6> on input line 71.

[1

] (./xelatex_test_.aux) ) 
Here is how much of TeX's memory you used:
 951 strings out of 479417
 15040 string characters out of 5888071
 251779 words of memory out of 5000000
 18506 multiletter control sequences out of 15000+600000
 535082 words of font info for 34 fonts, out of 8000000 for 9000
 1348 hyphenation exceptions out of 8191
 30i,5n,25p,223b,104s stack positions out of 5000i,500n,10000p,200000b,80000s

Output written on xelatex_test_.pdf (1 page).

Can someone please help find the root cause?

Ref:

EDIT

I have narrowed down the issue to the following MWE:

\documentclass[12pt]{article}%

\usepackage{graphicx}%

\begin{document}%
\includegraphics{test_0}%
\end{document}%

Comparing the results of MiKTeX's pdflatex and xelatex I notice both the vertical and horizontal differences. Interestingly, without specifying the 12pt the horizontal difference is lost but vertical is still present.

4
+50

This looks like a miktex bug. It rounds images size to full pt values:

\documentclass{article}

\setbox0=\hbox{\XeTeXpdffile example-image-a.pdf\relax}
\showthe\wd0
\showthe\ht0


\setbox0=\hbox{\XeTeXpicfile example-image-a.jpg\relax}
\showthe\wd0
\showthe\ht0

\begin{document}
blub
\end{document}

gives with miktex:

> 321.0pt.
l.18 \showthe\wd0
                 
? 
> 240.0pt.
l.19 \showthe\ht0
                 
? 
> 401.0pt.
l.23 \showthe\wd0
                 
? 
> 301.0pt.
l.24 \showthe\ht0
                 

and with texlive

> 321.20001pt.
l.18 \showthe\wd0
                 
? 
> 240.9pt.
l.19 \showthe\ht0
                 
? 
> 401.5pt.
l.23 \showthe\wd0
                 
? 
> 301.125pt.
l.24 \showthe\ht0
| improve this answer | |

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.