XeTeX
andLuaTeX
better support fonts, scripting, Unicode, and other compatibilities thanpdfTeX
.- When working
XeTeX
, usefontspec
(andxeCJK
for CJK support) packages to set fonts; when workingLuaTeX
, usefontspec
and/orluaotfload
packages to set fonts.. There is no default CJK font in bothXeTeX
andLuaTeX
currently. tcolorbox
,hyperref
, andunicode-math
packages should be loaded after all other packages.amsmath
should be loaded beforemathtools
;mathtools
should be loaded beforeunicode-math
.- When using
unicode-math
, math fonts should only be set with\setmathfont
instead of\usepackage
because that will either conflict withunicode-math
(such as when you loadunicode-math
beforemathalfa
), be overriden byunicode-math
(such as when you loadunicode-math
aftermathalfa
), or break the font setting ofunicode-math
(such as when you loadeuler
ormathspec
with presence ofunicode-math
). Thoughfontspec
is loaded automatically byunicode-math
, it's ok and common to load it separately at beginning. unicode-math
(as well as some other packages) sets\mathcal
and\mathbfcal
the same as\mathscr
and\mathbfscr
. A possible approach to set them differently is to set a different font or a different stylistic set for one of them. It is common to set\mathcal
and\mathbfcal
to a font style more similar to the traditional one, such as\setmathfont{XITS Math}\setmathfont[range={cal,bfcal},StylisticSet=1]{XITS Math}
.- Use the
H
option for floats provided byfloat
package and the\FloatBarrier
after floats provided byplaceins
package to force floats to be placed in the wanted place. - It is usually advisable to use
geometry
,nowidow
, etc. for page layout settings instead of manually adjusting. - It is usually unadvisable to use
\paragraph
and\subparagraph
excessively. Consideritemize
orenumitem
for lists to ensure it doesn't flow out of page and enjoy label customization provided byenumitem
package. - Keep in mind that macro expansion (such as the
\ifnum
provided byetoolbox
) is done before entering LaTeX engine level (such as the\NewDocumentCommand
provided byxparse
) during compiling.