I’d like to use the microtype and xeCJK packages in one document:

\expandafter\let\csname xetex_suppressfontnotfounderror:D\endcsname
% the above two lines are a necessary fix to a temporary problem
% of a package lagging behind in CTAN
\setCJKmainfont{Source Han Sans}
Hello world.

but keep getting this error:

!Undefined control sequence
<argument> \ifpdf 

                  \expandafter \@secondoftwo \else \expandafter \@firstoftwo...
l.7 \begin{document}

I do not get the error if I remove either xeCJK or microtype. None of the packages list an incompatibility in their respective documentation. Is there an error on my side, or a way to solve the problem?

2 Answers 2


Seems to be a bug in one of the loaded packages using this without definition, but you can add


to the preamble to get things working.

Seems to be line 1174 of microtype.sty . One possible fix would be adding \RequirePackage{ifpdf} as in:


I'll ping the author.

  • But, why does it work when I remove the xeCJK package?
    – Philipp
    Commented Sep 28, 2015 at 13:52
  • 1
    @Philipp that line is in a conditional block of code only used in the cjk case (no idea what it is trying to do but that is only time it does it:-) Commented Sep 28, 2015 at 13:54
  • Thanks. It should only be temporary then, with a fix at hand and the package well-maintained.
    – Philipp
    Commented Sep 28, 2015 at 13:59

The xeCJK package fools LaTeX into thinking that CJKutf8.sty has been loaded:

78 \clist_map_inline:nn { CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK }
79   {
80     \xeCJK_if_package_loaded:nTF {#1}
81       { \msg_error:nnn { xeCJK } { incompatible-package } {#1} }
82       { \tl_const:cn { ver@ #1 . \c__xeCJK_package_ext_tl } { 9999/99/99 } }
83   }

Next, microtype.sty has

1165 \MT@addto@setup{%
1166   \@ifpackageloaded{CJK}{%
1167     \@ifpackagelater{CJK}{2006/10/17}% 4.7.0
1168       {\def\MT@orig@pickupfont{\CJK@ifundefined\CJK@plane}}%
1169       {\def\MT@orig@pickupfont{\@ifundefined{CJK@plane}}}%
1170     \g@addto@macro\MT@orig@pickupfont
1171       {{\expandafter\ifx\font@name\relax\define@newfont\fi}}%
1172     \@ifpackageloaded{CJKutf8}%
1173       {\@ifpackagelater{CJKutf8}{2008/05/22}% 4.8.0
1174         {\ifpdf\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}%
1175         {\@firstoftwo}}%
1176       {\@firstoftwo}%

and here the problem shows, because CJKutf8.sty has

32 \RequirePackage{ifpdf}

but the package code is not input, so the package is not read in.

The xeCJK package should load ifpdf, because the issue is its fault. On the other hand it's very reasonable that also microtype loads it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .