# Half of a document in pdfLaTeX, half in XeLaTeX

As far as I know, I cannot use `microtype` in XeLaTeX, and cannot use `fontspec` in pdfLaTeX. I am rendering Chinese symbols only on one page, and I need this line: `\newfontfamily{\J}[Scale=0.85]{Osaka}` to render the symbols properly.

I want to use `microtype` and `fontspec` at the same time; is it possible to tell latex to switch into "pdfLaTeX" mode to render the first half of the document, and then switch back into XeLaTeX to render the other half?

-
Have you tried LuaLaTeX? `fontspec` and parts of `microtype` work with it. –  doncherry Dec 21 '12 at 17:51
I haven't tried LuaLaTeX. I'll give it a shot now. Is there a fundamental syntax change between pdflatex and LuaLaTeX? –  alexy13 Dec 21 '12 at 18:03
Or use `pdfpages` to insert the second half (pre-generated with `xelatex`) into the main document generated with `pdflatex`. –  JLDiaz Dec 21 '12 at 18:19
@alexy13 See my answer. Basically: No, the syntax is the same; the packages typically loaded are a mixture of pdfLaTeX and XeLaTeX packages. –  doncherry Dec 21 '12 at 19:10
If the Chinese part is restricted to one page it would probably be best to compile it with XeTeX and include it using `pdfpages`. –  Alan Munn Dec 21 '12 at 20:04

I recommend LuaLaTeX, since it supports `fontspec` and parts of `microtype`: protrusion and expansion; whereas kerning, spacing, and tracking are not (yet?) supported, cf. the `microtype` documentation.

For a little background on LuaLaTeX, see:

On your actual question: If you need to switch compilers mid-page, I’m not sure there’s any option other than manually puzzling the pieces together, e.g. with `pdfpages`, as JLDiaz suggested. Also note that there is a beta version of `microtype` that supports XeLaTeX, but I don’t know which features; see e.g. neic.dk - XeLaTeX with microtype on TeX-Live 2012.

-
Yes, I have experiment with LuaLaTeX and recommend too. It is relative simple to port pdfLaTeX (if you code your doc in UTF-8) and XeLaTeX to LuaTeX. –  lazyboy Dec 21 '12 at 19:48
This is one of the cases where LuaTeX and XeTeX are not equivalent. The standard package for dealing with Asian languages `xecjk` makes extensive use of XeTeX-specific functionality, especially `xetexinterchartoks`, which doesn't exist in LuaTeX. See Is there a LuaTeX analogue to xetexinterchartoks. –  Alan Munn Dec 21 '12 at 20:03
@AlanMunn: Thanks, good to know! I've only ever used Latin (and a wee bit of Greek) script with either compiler. –  doncherry Dec 21 '12 at 20:17

You can't change the engine midway through a document. Although much of the time LuaTeX can be used as a drop-in alternative to XeTeX, in the case of Chinese it's not usually true.

If you are using `xecjk` to compile the Chinese portion of the text, then it will not work to compile the document with LuaTeX, since `xecjk` makes extensive use of functionality that is specific to XeTeX, specifically `xeinterchartoks`. See:

for more details on this.

In this situation it would be best to compile the Chinese portion of the document separately using XeTeX and then include the page(s) into the main document using the `pdfpages` package.

For some more useful information about mixed script documents involving `xecjk` see especially Leo Liu's answer to:

-