Interaction between KOMA, eulerpx, \chapter, and \mathbf: Use of \reserved@a doesn't match its definition
Well, the eulerpx
package says
%% Get rid of the existing \mathbf font
\let\mathbf=\relax
which is not really a good thing to do.
What is the problem? The \DeclareMathAlphabet{\mathbf}
command that follows, will not change the internal definition of \mathbf
. This is witnessed by doing
\expandafter\show\csname mathf \endcsname
after the first \(\mathbf{foo}\)
(because math alphabets are really only allocated at first usage). This will show
> \mathbf =macro:
->\relax \ifmmode \else \non@alpherr \mathbf \fi \use@mathgroup \M@OT1 {8}.
on the terminal, which is the same as you get without loading eulerpx
, only the final number will change. On the other hand, removing the bad \let\mathbf=\relax
line, we get
> \mathbf =macro:
->\relax \ifmmode \else \non@alpherr \mathbf \fi \use@mathgroup \M@U {8}.
Can you see the small difference? Well, that's the one. Indeed, the issue disappears.
There is no need whatsoever to “get rid of the existing \mathbf
font”. Math alphabets are allocated “on demand”, so there is no existing \mathbf
font. There is a \mathbf
command, but it will do a shake to the font selection scheme at its first usage in order to pick up the requested font.
(There are a few other glitches in eulerpx
, actually.)
In the Modern Toolchain
Since you mentioned you’re able to use LuaLaTeX or XeLaTeX, you could download the OpenType version of Euler and use unicode-math
. In Linux, save euler.otf
to ~/.fonts/
to install it only for yourself, or to /usr/local/share/fonts/
to install it system-wide. (Subdirectories also work.)
A good companion sans-serif font by the same designer as AMS Euler and Palatino would be Optima, whose clone URW Classico is available via TUG’s getnonfreefonts
script. (You want to install it to your TEXMFLOCAL
directory, with --sys
.)
\documentclass{scrreport}
\usepackage[math-style=upright]{unicode-math}
\defaultfontfeatures{ Scale=MatchLowercase, Ligatures=TeX }
\setmainfont{TeX Gyre Pagella}[Scale=1.0]
\setsansfont{URW Classico}
\setmonofont{Inconsolata}
\setmathfont{Asana Math}
\setmathfont{euler.otf}[range={up/{Latin,latin,Greek,greek},
bfup/{Latin,latin,Greek,greek},
cal,bfcal,frak,bffrak}]
\newcommand\vectorsym[1]{\symbf{#1}}
\begin{document}
\[ a \vectorsym{i} \times b \vectorsym{j} = ab \vectorsym{k}
\quad\mathbf{iff}\quad \vectorsym{i} \cdot \vectorsym{j} = 0 \]
\end{document}
This preamble should give you similar output to eulerpx
, except that \mathbf
gives you the bold text font. (The least-contrived example I could think of was wanting to emphasize the word iff. Notice the ff ligature and the difference between the i in iff and the basis vector.) To get bold math letters for vectors, use \symbf
.
You could instead add the bf=sym
option to unicode-math
, which makes \mathbf
an alias for \symbf
. You then, if you ever need a bit of bold text in math mode, would write something like \textnormal{\bfseries iff}
.
You can change the \mathbf
font with the BoldFont=
option of \setmathrm
, e.g.
\setmathrm{URWClassico}[
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic,
Extension = .otf]
There is also a \setboldmathrm
command, but that changes the output of \mathrm
in \mathversion{bold}
, which unfortunately this set-up does not support.
If you would prefer ISO style, with Euler only for constants such as e, i and π, you can change [math-style=upright]
to [math-style=ISO]
.
If you don’t like the spacing of Euler’s subscripts and superscripts, you can pass \setmathfont
the options script-features={}
and sscript-features={}
. This will also disable the wider, more-legible letters.
A Workaround for PDFLaTeX
If you need to use legacy 8-bit fonts, eulerpx
is compatible with bm
for bold vector symbols, and you can use \textnormal{\bfseries ...}
for bold text in math mode.
\documentclass{scrreport}
\usepackage{amsmath,eulerpx,bm,tgpagella,classico,inconsolata}
\newcommand\vectorsym[1]{\boldsymbol{#1}}
\begin{document}
\[ a \vectorsym{i} \times b \vectorsym{j} = ab \vectorsym{k}
\quad\textnormal{\bfseries iff}\quad \vectorsym{i} \cdot \vectorsym{j} = 0 \]
\end{document}