5

I've added the following packages:

\usepackage{fontspec}
\usepackage{xunicode,xltxtra,url,parskip} 
\usepackage[usenames,dvipsnames]{xcolor} 
\usepackage{hyperref} 
\definecolor{linkcolour}{rgb}{0,0.2,0.6} 
\hypersetup{colorlinks,breaklinks,urlcolor=linkcolour,linkcolor=linkcolour} 

In addition, I started compiling(?) in XeLaTeX instead of pdfLaTeX.

As a consequence, in the math environment, the boldface (i.e. \mathbf) in combination with Greek letters does not work (whereas the latin letter do work). Just to clarify: I can still compile my code, but the Greek letter have become invisible in the output.

I've tried to use the \bm package to attempt to circumvent this problem, but it spits out the following error:

! Undefined control sequence.
\Call@AtVeryEndDocument ...cumentHook \@undefined 
                                              \global \let \Call@AtVeryE...

Does anybody know how to fix this problem?

Hunter
  • 469
  • my packages always work:-) That error is not generated by bm please (always) produce a complete small document that shows the problem. – David Carlisle Oct 31 '13 at 16:25
  • Oh I should say bm doesn't really work with unicode-math, it is designed for classic 8bit math font setups. – David Carlisle Oct 31 '13 at 16:26
  • @DavidCarlisle Hehe, sorry, not trying to step on anybody toes; I'm sure it is my incompetency with LaTeX. It is difficult to reproduce a small document, because I'm using man different files and let it compile by 1 main file (difficult to explain for me because I don't speak the LaTeX lingo and English is not my first language, but I hope you know what I mean). But it is exactly, how I described in my original post. The problem arrived when I added those packages. Before that everything was working fine. – Hunter Oct 31 '13 at 16:27
  • 1
    \usepackage[no-math]{fontspec} should do. Don't load xunicode and xltxtra. Some outdated guides tell to, but they're wrong. You should be aware of the fact that \mathbf only works with uppercase Greek letters (but this has always been so). – egreg Oct 31 '13 at 16:32
  • Ah great. It work exactly like berfore with mathbf, so I don't need to manually change everything to bm. Thank you @egreg!! – Hunter Oct 31 '13 at 16:38
  • 1
    @Hunter You can even do better. ;-) – egreg Oct 31 '13 at 16:58

1 Answers1

6

When you load fontspec also the font for math upright letters is changed to use the default text font. The Greek letters in this font are not where LaTeX expects them to be: with the standard definition, \Phi points to slot 0x08, while the uppercase Phi in Unicode is at U+03A6.

The command \mathbf, in standard LaTeX, only works with Latin letters and uppercase Greek. You can revert to the standard behavior by loading

\usepackage[no-math]{fontspec}

that will use the standard Computer Modern font for upright math characters. But there's no point in not doing the big step and load

\usepackage{unicode-math}

but you need \symbf rather than \mathbf (also for Latin letters).

See the following example:

\documentclass{article}
\usepackage{unicode-math}
\begin{document}

$\symbf{\Phi}+\symbf{\alpha}$

$\Phi+\alpha$
\end{document}

that produces

enter image description here

If you don't want to do the big step, you still can get \mathbf to work with uppercase Greek; just teach XeLaTeX where to go and find the uppercase Greek letters.

\documentclass{article}
\usepackage{fontspec}

\AtBeginDocument{
  \Umathchardef\Gamma   = 7 0 "0393
  \Umathchardef\Delta   = 7 0 "0394
  \Umathchardef\Theta   = 7 0 "0398
  \Umathchardef\Lambda  = 7 0 "039B
  \Umathchardef\Xi      = 7 0 "039E
  \Umathchardef\Pi      = 7 0 "03A0
  \Umathchardef\Sigma   = 7 0 "03A3
  \Umathchardef\Upsilon = 7 0 "03A5
  \Umathchardef\Phi     = 7 0 "03A6
  \Umathchardef\Psi     = 7 0 "03A8
  \Umathchardef\Omega   = 7 0 "03A9
}

\begin{document}
$\Gamma+\Delta+\Theta+\Lambda+\Xi+\Pi+\Sigma+
 \Upsilon+\Phi+\Psi+\Omega$

$\mathbf{\Gamma}+\mathbf{\Delta}+\mathbf{\Theta}+\mathbf{\Lambda}+
 \mathbf{\Xi}+\mathbf{\Pi}+\mathbf{\Sigma}+\mathbf{\Upsilon}+
 \mathbf{\Phi}+\mathbf{\Psi}+\mathbf{\Omega}$

\end{document}

enter image description here


Although you can find somewhere that xunicode and xltxtra are recommended with XeLaTeX, the information is outdated and they should not be loaded. Only xltxtra can, in the unusual situation that you really need the features it provides.

egreg
  • 1,121,712
  • Wow, thank you! Unfortunately, the unicode-math gives me the error: “improper alphabetic constant”. This is very similar to the problem described here:http://tex.stackexchange.com/questions/69331/strange-error-when-unicode-math-and-hyperref-are-combined-in-xelatex, however their solution does not work for me. Nevertheless, your second suggestion works perfect for me. Thank you! – Hunter Oct 31 '13 at 18:09
  • dear @egreg, now the example you provided do not produce any bold greek letter (I tried with both XeLaTeX and LuaLaTeX). Could you update your answer? – oibaFox Mar 04 '20 at 09:30
  • 1
    @oibaFox I guess you meant the first document example; six years ago \mathbf was correct, now \symbf should be used. – egreg Mar 04 '20 at 09:58
  • I am sorry, I did not know. In fact, using \symbf it works. Thank you very much. – oibaFox Mar 04 '20 at 12:10