0

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 正楷書体M}
   \setCJKsansfont{EPSON 丸ゴシック体M}
   \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.

jamesh625
  • 349
  • 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 02: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 02: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 02: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 03: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 03:03
  • Why do you \setmainfont twice? – cfr May 25 '16 at 03:04
  • Thanks cfr, some very good ideas. I will try and implement some and see how it goes. :) Yes, I did realise that I \setmainfont twice. I was under the impression that both unicode-math and xeCJK allow me to do this, for different environments. I.e., the first affects how fonts are displayed in maths environments and the second in text. I'm assuming that this is not the case because I commented out unicode-maths and the fonts appear unaffected. However, compile time was not significantly reduced. Additionally, compiling without pdfpages did not reduce compile time. – jamesh625 May 25 '16 at 03:12
  • The only "special" thing in this document would be CJK characters, which I wouldn't think would increase compile time greatly. I also got rid of waysysym and textcomp because they weren't being used. – jamesh625 May 25 '16 at 03:12
  • It isn't clear whether you are asking about package loading time or run time at the document, You can see package loading time just look at the console output until it shows (filename.aux which is where the aux file is read at \begin{document} obviously the only way to speed up package loading is to load less packages. If you mean the run time for the rest of the document, it depends what is in the document which you have not shown. Also how slow is slow? when I started to use latex 15 minutes per page was quite common. – David Carlisle May 25 '16 at 08:27
  • I get errors with your package combination. E.g. ruby loads the incompatible cjk. – Ulrike Fischer May 25 '16 at 08:36
  • Yes, I got those errors too... Was just ignoring the errors for now as I want sure how to fix it... Also it's a separate question to the one above so couldn't post it here. – jamesh625 May 25 '16 at 21:53
  • @UlrikeFischer I posted that question here: http://tex.stackexchange.com/questions/311518/conflict-between-ruby-and-xecjk – jamesh625 May 26 '16 at 04:33
  • @DavidCarlisle You're going to say something like "Young people these days have no patience", I'm sure, but it takes about 20~30 seconds to compile and produce the PDF. I figured out (after lots of commenting out) that the bottleneck was not to do with how many packages I loaded, but rather to do with how many PDFs I included (or how large they were). Adding draft as an option on \includepdf reduces compile time to about 10 seconds. Commenting out the \includepdf reduces it to about 5. – jamesh625 May 26 '16 at 04:36
  • so what to do with this question? You could I suppose self answer, otherwise it's not really answerable by anyone else, using information available just in the question. – David Carlisle May 26 '16 at 06:48
  • @DavidCarlisle That sounds like a good idea. It may come in handy for someone else (doubtful, but still...). – jamesh625 May 26 '16 at 06:52

1 Answers1

1

Please see the comments to the original post.

To summarise, \includepdf was the real bottleneck, and compile time had little to do with the packages included. Using the option draft or commenting out the \includepdf greatly reduced compile time.

Thanks to all those who helped me find this workaround in order to reduce compile time while working on the draft.

jamesh625
  • 349