2

I'm using the awesome-cv class file (from here) to write a statement, but I'm unhappy with the math fonts. Specifically, I don't like the result of using \mathbb. Also, math operators (even predefined ones like \log) are italicized while I would like them to be as in \mathrm (as shown below).

I tried installing a different font (Palatino) in the fonts directory, but this did not affect the math font at all.

I would even be willing to change the font entirely using, e.g., \usepackage{mathpazo}, but it doesn't seem to change anything, probably due to specifications in the awesome-cv.cls file.

The awesome-cv.cls file includes the line \RequirePackage[math-style=TeX,vargreek-shape=unicode]{unicode-math}, and it turned out that configuring the math font with this package was most of my problem. Some useful posts: Changing the operator font with unicode-math loaded, Unicode-math changes font outside of range, lost symbols with unicode-math

Final update thanks to Davislor's comments.

MWE:

% Important note:
% This template must be compiled with XeLaTeX, the below lines will ensure this
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[letterpaper]{awesome-cv}
\geometry{left=2cm, top=1.5cm, right=2cm, bottom=2cm, footskip=.5cm}
\fontdir[fonts/]

% math packages

%\usepackage{amssymb} % throws errors/conflicts
\usepackage{amsfonts}
\usepackage{amsmath}

% math commands

% new commands
\renewcommand{\C}{\mathbb C}
\newcommand{\R}{\mathbb R}
\newcommand{\Q}{\mathbb Q}
\newcommand{\Z}{\mathbb Z}

% new operators
\DeclareMathOperator{\Gal}{Gal}

\setmathfont[Path=fonts/STIXv2.0.0/OTF/]{STIX2Math.otf}
%\setmathfont[Path=fonts/,range=\sqrt]{SourceSansPro-Regular.otf}
\setmathfont[range=\mathnormal,Path=fonts/]{SourceSansPro-It.otf}

\ExplSyntaxOn
\makeatletter
\renewcommand{\operator@font}{\um_switchto_mathsf:}
\makeatother
\ExplSyntaxOff


%\setmainfont[Path=fonts/]{SourceSansPro-Regular.otf}
%\setmathfont[Path=fonts/]{SourceSansPro-It.otf}

\begin{document}

%----------------------------------------------------------------------------------------
%   LETTER CONTENT
%----------------------------------------------------------------------------------------

\begin{cvletter}

%------------------------------------------------

$$
\log(N) \qquad \mathrm{log}(N)
$$

$$
\C \quad \R \quad \Q \quad \Z
$$

$$
\Gal(K/\Q) \quad \mathrm{Gal}(K/\Q)
$$

$$
\varphi: X \to Y
$$

\end{cvletter}

\end{document}

enter image description here

Thanks for any help!

  • 1
    Not a complete answer, because I'm not at home to test. From the snippet, your class is loading OpenType fonts with fontspec. You therefore probably want to load unicode-math and use the \setmathfont command. (You would want \setmathfont[range=it]{SourceSansPro-It.otf} and so on to match your text font.) You might also be able to use mathspec. – Davislor Oct 25 '18 at 21:21
  • 1
    Yes, you got it. You need to set your main math font first, for example, \setmathfont{STIX Two Math}, and then override one or more of the math alphabets (up, it, by up, bfit, etc.). I would also suggest you set \defaultfontfeatures{Scale=MatchLowercase} before you start declaring any fonts. That will ensure they come out properly scaled. – Davislor Oct 26 '18 at 0:32
  • 1
    There are a few solutions for the remaining \mathrm{Gal} problem. Since you appear to be using this font only for operator names, the simplest workaround is to use \operatorname{Gal}. You can also, however, \setmathfont[range=up]{SourceSansPro-Regular.otf} and use \symup, as well as overriding \setoperatorfont and \setmathrm if you need to. – Davislor Oct 26 '18 at 0:48
  • 1
    You're welcome. I'm on my phone right now, but I should be able to test an answer and make a sample image when I get home. – Davislor Oct 26 '18 at 1:55
  • 1
    @André3000 Okay, posted. (If this is your first question, by the way, the green accept button is different from the upvote button. Apologies if you knew that.) – Davislor Oct 26 '18 at 19:26
2

To turn my comments into an answer: you should seriously consider whether you want to write your paper in a non-standard CV class. However, if you really do, here is what I got to work.

Note that I needed to make several changes to your .cls file to get it to compile at all in TeX Live 2018. I had to change a \newfontfamily to \setfontfamily for a family that had previously been defined in a package it loaded. (A recent version of fontspec made this compatibility-breaking change.) I also had it use the more recent version of the fonts installed on my system. The sourcesanspro package also needed [sfdefault]. That having been done, the problem with the operator names was that the class file loaded unicode-math before you load amsmath. Adding \RequirePackage{amsmath} before \documentclass enabled some hackish workarounds.

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\RequirePackage{amsmath}
\documentclass[letterpaper]{awesome-cv}
\geometry{left=2cm, top=1.5cm, right=2cm, bottom=2cm, footskip=.5cm}

%% Math Font setup
\defaultfontfeatures{Scale=MatchLowercase}
\unimathsetup{partial=upright} % Source Sans Pro contains \partial at U+2202.
% If you should actually need \mitpartial, \mbfpartial, etc., load them from a
% math font.  If you want an italic \partial, load from SourceSansPro-It.
\setmathfont{STIX2Math.otf}
% Sets math symbols present in Source Sans Pro and that work. You still might
% not, e.g. want ≥ and ≤ from the text font if ≰ does not match them.
\setmathfont[range={up,"21,"23-"25,"2A-"2F,"5C,"5E-"5F,"7E,
                      `¬,`±,`·,`×,`÷,`≤,`≥,`≠,`≈,`∞,`√}
              ]{SourceSansPro-Regular.otf}
% Must load separately, or this will prevent autodetection of the upright math
% alphabet:
\setmathfont[range=\partial]{SourceSansPro-Regular.otf}
\setmathfont[range={it}]{SourceSansPro-RegularIt.otf}
\setmathfont[range={bfup}]{SourceSansPro-Bold.otf}
\setmathfont[range={bfit}]{SourceSansPro-BoldIt.otf}
% Greek variant letters Missing from Source Sans Pro:
\setmathfont[range={\mupvarepsilon,\mupvarphi,\mupvartheta,\mupvarpi,
                      \mupvarkappa,\mupvarrho,\mupvarTheta,\nabla,
                      \mitvarepsilon,\mitvarphi,\mitvartheta,\mitvarpi,
                      \mitvarkappa,\mitvarrho,\mitvarTheta,\mitnabla,
                      \mbfvarepsilon,\mbfvarphi,\mbfvartheta,\mbfvarpi,
                      \mbfvarkappa,\mbfvarrho,\mbfvarTheta,\mbfnabla,
                      \mbfitvarepsilon,\mbfitvarphi,\mbfitvartheta,
                      \mbfitvarpi,\mbfitvarkappa,\mbfitvarrho,
                      \mbfitvarTheta,\mbfitnabla }
               ]{GFSNeohellenicMath.otf}
% By default, \mathscr is the same as \mathcal, but several math fonts provde
% two separate alphabets as variants.
\setmathfont[range={scr,bfscr},
               Scale=MatchUppercase,
               StylisticSet=1
              ]{STIX2Math.otf}

% Workaround for \operatorname and \mathrm:
\setmathrm{SourceSansPro}[
  UprightFont = *-Regular ,
  BoldFont = *-Bold ,
  Ligatures = {Common, TeX },
  Extension = .otf ]
\setoperatorfont\mathup

% math commands

% new commands
\renewcommand{\C}{\mathbb C}
\newcommand{\R}{\mathbb R}
\newcommand{\Q}{\mathbb Q}
\newcommand{\Z}{\mathbb Z}

% new operators
\DeclareMathOperator{\Gal}{Gal}

\begin{document}

%----------------------------------------------------------------------------------------
%   LETTER CONTENT
%----------------------------------------------------------------------------------------

\begin{cvletter}

%------------------------------------------------

\[
\log(N) \qquad \mathrm{log}(N)
\]
\[
\C \quad \R \quad \Q \quad \Z
\]
\[
\Gal(K/\Q) \quad \mathrm{Gal}(K/\Q)
\]
\[
\varphi: X \to Y
\]
\[
\symup{i} \symup{e} \symup{\pi} \cdot
\Biggl\{ \Biggl[ \Biggl( \biggl\{ \biggl[ \biggl( \Bigl\{ \Bigl[ \Bigl(
\nabla \frac{\partial \vartheta}{\partial t}
\Bigr) \Bigr] \Bigr\} \biggr) \biggr] \biggr\} \Biggr) \Biggr] \Biggr\}        
\]

\end{cvletter}

\end{document}

Font Sample

ETA: Went back and tweaked it a bit more. Now resizing delimiters and \nabla work.

That image is an unusual mashup of several different fonts. I loaded the math symbols that work correctly from Source Sans Pro, then took the variant Greek letters that are not present from GFS Neohellenic, then fell back to STIX Two Math for the remaining symbols. (You might want the upright math symbols to be different from the body text.)

You shouldn’t load amsfonts or amssymb with unicode-math, as they use legacy font encodings and there are OpenType replacements. You also should use the \setoperatorfont command from unicode-math instead of attempting to redefine operator@font.

There is at least one limitation I left in rather than making the font selection even more overcomplicated. You would need to load yet another math font with [range={\partial,\mitpartial,\mbfpartial,\mbfitpartial}] if for some reason you need to use the upright, italic, bold and bold italic forms of the partial derivative symbol in the same document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.