Skip to content

Latest commit

 

History

History
12 lines (11 loc) · 2.38 KB

LaTeX Best Practices.md

File metadata and controls

12 lines (11 loc) · 2.38 KB

LaTeX Best Practices

  • XeTeX and LuaTeX better support fonts, scripting, Unicode, and other compatibilities than pdfTeX.
  • When working XeTeX, use fontspec (and xeCJK for CJK support) packages to set fonts; when working LuaTeX, use fontspec and/or luaotfload packages to set fonts.. There is no default CJK font in both XeTeX and LuaTeX currently.
  • tcolorbox, hyperref, and unicode-math packages should be loaded after all other packages. amsmath should be loaded before mathtools; mathtools should be loaded before unicode-math.
  • When using unicode-math, math fonts should only be set with \setmathfont instead of \usepackage because that will either conflict with unicode-math (such as when you load unicode-math before mathalfa), be overriden by unicode-math (such as when you load unicode-math after mathalfa), or break the font setting of unicode-math (such as when you load euler or mathspec with presence of unicode-math). Though fontspec is loaded automatically by unicode-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 by float package and the \FloatBarrier after floats provided by placeins 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. Consider itemize or enumitem for lists to ensure it doesn't flow out of page and enjoy label customization provided by enumitem package.
  • Keep in mind that macro expansion (such as the \ifnum provided by etoolbox) is done before entering LaTeX engine level (such as the \NewDocumentCommand provided by xparse) during compiling.