4

Follow up question for Use Arial font in KOMA Class for section Headings

  • I need to the typical italic, math-font for equations using siunitx and normal Arial for headings and text.

  • I would like to have normal Arial font where I use siunitx \SI{}{} in an table environment.

  • Basically I want everything in Arial, only equations and SI units in them should have the italic math font.

Is this possible?

Here is my MWE which shows all possible situations in my text.

\documentclass[12pt, numbers=noenddot,parskip,headings=small,headsepline,listof=nochaptergap, listof=totoc,index=totoc]{scrreprt}
\usepackage[a4paper, includehead, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\usepackage{textcomp}
\usepackage{fontspec}
\setsansfont{Arial}
\renewcommand\familydefault{\sfdefault}
\usepackage[ngerman]{babel}
\usepackage{array,booktabs,amsmath}

\usepackage[group-separator={.}]{siunitx}
\sisetup{load-configurations = abbreviations}
\sisetup{locale = DE}
\sisetup{per-mode=symbol}
\sisetup{detect-all, math-rm = \ensuremath}
\sisetup{detect-all}                                        


    \begin{document}

    \chapter{Heading}

    Test Test

    \begin{equation}
    \begin{aligned}
    t_a  = & \frac{v}{a} \\
    h_a  = & \frac{1}{2} \times a \times {t_a}^2 \\
    h_v  = & h_t - h_a - h_r \\
    t_v  = & \frac{h_v}{v} \\
    t_t  = & 2 \times (t_a + t_v + t_r + t_d)
    \end{aligned}
    \end{equation}  
    Equation 1.1 works fine. No SI in there.
    \begin{equation}
    \begin{aligned}
    h_a  = & \frac{1}{2} \times a \times {t_a}^2 \\
    h_v  = & \SI{120}{\metre\per\second\squared}\\
    \end{aligned}
    \end{equation}  
    Equation 1.2 does not look right, because of SI.

    \begin{align*}
    t_a &= \frac{\SI{6}{\metre\per\second}}{\SI{0,6}{\metre\per\second\squared}} \\
    &= \SI{10}{\second}
    \\
    h_a &= \frac{1}{2} \times \SI{6}{\metre\per\second\squared} \times {\SI{10}{\second}}^2 \\
    &= \SI{30}{\metre}
    \\
    h_v  &=  \SI{300}{\metre} - \SI{30}{\metre} - \SI{30}{\metre} \\
    &= \SI{240}{\metre}          
    \\          
    t_v  &=  \frac{\SI{240}{\metre}}{\SI{6}{\metre\per\second}} \\
    &= \SI{40}{\second}          
    \\          
    t_t  &= 2 \times (\SI{10}{\second} + \SI{40}{\second} + \SI{8}{\second}  + \SI{120}{\second}) \\
    &= \SI{356}{\second}                  
    \end{align*}
    Not working at all....

    \begin{table}[h!]
        \centering
        \begin{tabular}{r l r l}
            $t_a $:&Beschleunigungsdauer  &$v$:&Geschwindigkeit [\SI{}{\metre\per\second}] \\
    \end{tabular}\nonumber
    \end{table}
    This is fine.
    \end{document}
5
  • As you might have noticed I am using detect-all but it does not seem to work. Am I using it wrong? Jul 23, 2017 at 20:22
  • 3
    You need to set \sisetup{math-rm=\mathrm} back again after \begin{document}. See tex.stackexchange.com/a/66743/117534. As for the table headings, if it is not frequent, you can just pass detect-all as an option to \si to get it back to sans serif.
    – Troy
    Jul 24, 2017 at 4:09
  • 2
    As an aside (off-topic), the alignment tabs for align should be placed before the = sign for proper spacing.
    – Troy
    Jul 24, 2017 at 4:13
  • @Skillmon You are wrong. \familydefault is long by default: \documentclass{article} \begin{document} \show\familydefault \end{document} gives > \familydefault=\long macro: ->\rmdefault . Jul 24, 2017 at 6:46
  • @Schweinebacke interesting, I wonder why it is long though...
    – Skillmon
    Jul 24, 2017 at 11:35

1 Answer 1

9

The problem is that siunitx detects the font family by comparing the current family with the \sffamily -- and if both are equal as in your case it assumes that you want math-sf/\mathsf.

One can demonstrate the effect by using a slightly different sans font. I also use the [no-math] option for fontspec to avoid that it changes the mathrm and mathsf fonts:

\documentclass[]{scrreprt}    
\usepackage[no-math]{fontspec}
\setmainfont{Arial}
\setsansfont{Arial}%[Scale=1.01] %activate to see the difference.
\usepackage[ngerman]{babel}

\usepackage[]{siunitx}
\sisetup{load-configurations = abbreviations}
\sisetup{locale = DE,group-separator={.}}
\sisetup{per-mode=symbol}
\sisetup{detect-all}

\begin{document}

\chapter{Heading}

Test  

\SI{10}{\meter} $\SI{10}{\meter}$  

$\mathrm{mathrm} \mathsf{mathsf}$

\end{document}

without the Scale option mathsf is used in math:

enter image description here

with the Scale option mathrm is used in math:

enter image description here

Imho it is better to keep the three standard families (rm, sf and tt) distinct. If you want your main font to be Arial, set it with \setmainfont. And if you want your headings to use the main font too, use the option that does it:

\documentclass[egregdoesnotlikesansseriftitles]{scrreprt}
\usepackage{textcomp}
\usepackage[no-math]{fontspec}
\setmainfont{Arial}

\usepackage[ngerman]{babel}
\usepackage{array,booktabs,amsmath}

\usepackage[]{siunitx}
\sisetup{load-configurations = abbreviations}
\sisetup{locale = DE,group-separator={.}}
\sisetup{per-mode=symbol}
\sisetup{detect-all}

\begin{document}

\chapter{Heading}

Test  

\SI{10}{\meter} $\SI{10}{\meter}$  

$\mathrm{mathrm} \mathsf{mathsf}$

\end{document}
6
  • Thank you for the input. Maybe I have to clarify: In your example you now have 3 types of math font: mathrm, mathsf and if if typeset something like $ 10 $ or $ h_a$ the regular timesnewroman math/italic font. Is there a way to have the mathsf for those non, siunitx type of situations? Or is this not even the best practice and would I want to have other font for units? Jul 24, 2017 at 8:12
  • 1
    A lot is possible but what font to choose for mathrm and mathsf or as standard math font is a new question. Your current math font is not times, it is computer modern. Jul 24, 2017 at 8:26
  • Ah, I just grasped the concept of it. I could make the changes I wanted and I works fine, thanks! Jul 24, 2017 at 8:34
  • I get ! Undefined control sequence. <argument> \c_sys_engine_xetex_bool...
    – Arzigoglu
    Jul 24, 2017 at 9:23
  • 1
    @Arzigoglu See tex.stackexchange.com/questions/382940/… Jul 24, 2017 at 9:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .