I got a weird problem with the fontspec
package and the graphicx
package. Let's see the MWE first.
%!TEX program = xelatex
\documentclass{article}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\newfontfamily\test[AutoFakeBold = 5]{Times New Roman}
\begin{document}
\test
Test
\textbf{Bold Test}
\includegraphics[scale = 0.1]{photo}
Words that shouldn't be bolded. Even if \textmd{textmd-ed}.
\end{document}
(source: sinaimg.cn)
In the preamble, I loaded the graphicx
package and the fontspec
package, then I set Times New Roman
as the default font of the text as well as the font of the test
command. In the definition of \test
, I enabled AutoFakeBold
. In the document body, between the two chains of text, I inserted a photo with the \includegraphics
command.
It's a normal manuscript, except that AutoFakeBold
was set to 5
to make the abnormal output more remarkable. After the compilation, however, the later line of text presented an unexpected output. That is, this line of text shouldn't be bolded.
Even more surprising is that, if one
- cancel the option passed to
\includegraphics
, - or put some more text after
\textbf{}
,
the problem will go away.
I suspect the problem lies in the FakeBold
mechanism of the fontspec
package and/or the key-val mechanism of the graphicx
package, but unfortunately, I don't read LaTeX3 codes, so I cannot locate it.
Maybe an issue should be posted to fontspec
or graphicx
, but before that, could someone provide me a quick fix to this problem?
EDIT 2015/01/05
Thanks to the help of [email protected], it seems to be a bug of XeTeX. See the new MWE.
% !TeX program = xetex
\font\x="[cmunrm.otf]"
\font\bx="[cmunrm.otf]:embolden=5;"
\x Test
{\bx Bold Test}
\XeTeXpicfile "example-image.png" width 1cm\relax
Words that shouldn't be bolded.
\tracingoutput=1
\showboxbreadth=\maxdimen
\showboxdepth=\maxdimen
\bye
(source: sinaimg.cn)
I made a ticket on xetex.sf and hope this will be fixed soon.
: )
;-)