# Improving compile time with xelatex

I'm currently compiling a document using xelatex.

I've included a lot of packages that I think slow it down.

Here's my preamble:

\documentclass{article}
\usepackage{cite}
\usepackage{pdfpages}
\usepackage{textcomp}
\usepackage{wasysym}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ruby}

\title{TITLE}
\author{ME}
\date{TODAY}

\usepackage{ifxetex}
\ifxetex
\usepackage{unicode-math}
\setmainfont[Numbers=OldStyle, Ligatures={Contextual},StylisticSet={1}]{Calluna}

\usepackage{xeCJK}
\setCJKmainfont{EPSON 正楷書体Ｍ}
\setCJKsansfont{EPSON 丸ゴシック体Ｍ}
\setmainfont{Calluna}
\setsansfont{Calibri}

\else
\usepackage[T1]{fontenc}
\fi

Is my inclusion of so many packages making xelatex take forever? How can I reduce the compile time of my document?

I think the problematic package is unicode-math, as compile time on other documents using this package is also long.

• What kind of answer do you want? The obvious one, from what you've said, is 'don't use unicode-math. I'm not sure what else somebody might say. In truth, XeTeX is slow no matter what in comparison with traditional TeX or pdfTeX. But for a long document, the vast majority of the compile time is almost certainly due to the content of document unless you load all the packages there are or something. Do you want textcomp when using XeTeX? What's the point of testing for XeTeX in this case? If the document needs xeCJK then [T1]{fontenc} won't cut it. So why not eliminate the conditional? – cfr May 25 '16 at 2:21
• I was hoping for an answer that lets me know if I've done one of the following: a) loaded extraneous packages (unicode-math and xeCJK may overlap); b) a workaround so that I can keep all my packages but don't have to e.g. compile all parts of the file each time, c) a better way of doing things overall because I'm a noob. I had the if statement because sometimes I use my organisation's computers that don't have xetex or some of the fonts I need. Is there a way of making CJK available regardless of compiler/packages? – jamesh625 May 25 '16 at 2:47
• a) We can't know without knowing what's in the document. Easiest way is to comment it out and see if it breaks. b) This is certainly an option. The best strategy would require more information about your workflow and document structure. c) I doubt anybody can say much from this information that you don't know already. d) Yes, but I think you are better off sticking to XeTeX. At any rate, the conditional code is pointless as it stands. If the installation doesn't even have XeTeX, it is either ancient or very limited. Given XeTeX, you could keep the fonts with the document and load by file name. – cfr May 25 '16 at 2:53
• For example, see cjk but I don't know if this is the current recommendation (beyond the recommendation being not to use TeX/pdfTeX). – cfr May 25 '16 at 3:00
• Consider using \includeonly if you are using \include or using \include if you are not. Consider adding draft to your class/package options. Consider externalising pictures if you use e.g. PGF/TikZ. Don't use your editor's quick build or whatever if it automatically runs additional tools, especially if it isn't very smart about it. – cfr May 25 '16 at 3:03