[Tex/LaTex] How to debug hanging xetex compilation


I'm experiencing a weird problem. After updating my MikTeX installation my thesis document no longer compiles. Compilation (with xelatex) hangs and takes up all of one of my CPU's cores.

However, if I take out one particular chapter (the chapters are in separate .tex files which I load with \input) compilation completes without any problems.

But, when I compile that particular chapter separably compilation also completes without problems.
In other words, the problem does not seem to be caused by the chapter itself, but rather by some combination of factors.
Also, I must stress that things worked fine until I updated MikTex.

Does anyone have any ideas on what might be causing this? Or maybe just some pointers on how I could debug this situation?

EDIT (1)

(removed, the problem was not related to images after all)

EDIT (2)

I did more research and it turns out it has something to do with greek letters in math mode.

I have traced to problem to a few math expressions (between $-signs) containing \mu and \alpha. These are in the aforementioned chapter.
If I comment out these expressions (or just remove \mu and \alpha from them) my whole thesis compiles without problem (so including the problematic chapter).

What makes this extra strange is that when I compile this chapter (with the \mu and \alpha expressions) in isolation — by commenting out the loading of all other chapters in my master file — everything works and the mu's and alpha's look fine in the pdf.

My guess it this might be a memory problem. Maybe some sort of font cache can not load the greek glyphs because it is already full with all the glyphs used elsewhere in my thesis. Does this make any sense?

Providing a MWE for this problem is hard because it simply does not seem to occur when the input is "minimal". However, this might be a relevant section of my preable:


%MATH FONT: Iwona Light
\usepackage[light,math]{iwona} %for basic math symbols

%AMS Blackboald (mathbb) font (used for mathematical fields)

\usepackage{mathspec} %Also loads fontspec(!)

%MAIN FONT and MATH digits and latin letters: Computer Modern Unicode (CMU) Bright (loaded by filenames to force use of OpenType versions)

%MATH greek letters: Greek font is Iwona Light (loaded by filenames to force use of OpenType versions)

%SANS FONT: idem (no need to set it because CMU Bright already is a sans serif font)

%MONOSPACE (typewrite) FONT: CMU Typewriter Text Light
\setmonofont[Scale=MatchLowercase]{CMU Typewriter Text Light}

\usepackage{xltxtra} %also loads xunicode

Best Answer

I was able to fix the problem with these 2 steps (both were necessary):

  • stopped using \setmathsfont(Greek){Iwona Light} (instead I rely only on \usepackage[light,math]{iwona} which was loaded anyway for symbols/largesymbols/etc. and also applies to greek letters like \alpha)
  • avoided all used of mathspec's "-feature (for custom spacing in math mode)

The compilation problem has not occurred ever since.

I should note that mathspec's "-'feature' was also mentioned as the source of xetex compilation hanging in the thread egreg referred to in the comments above.

The only downside of no longer using \setmathsfont(Greek) was that I could no longer type greek letters as unicode characters (so αβ instead of \alpha\beta). However I was able to fix that by making all greek characters active (based on their unicode-code) and replacing their occurances with the relevant math command, like so:


I got the idea from this blogpost: http://uucode.com/blog/2010/03/26/unicode-math-in-xelatex

I made a custom package (which I may release online if there is interest) in which I did this for all greek letters (upper & lower case). Also, the package makes it possible to use the greek chars in math AND text mode (by auto-wrapping a $-pair around the \alpha, \beta, ... when greek unicode chars appear in text mode).

I realize a better way to do this would be to use unicode-math, but I don't really like any of the fonts which work with that package (because there is no sans serif font afaik).

Related Question