6

Consider the following example. (The code is not my own.)

Code

\documentclass{article}

\usepackage{mathtools}
\usepackage{siunitx}

% Subscript text directly in math mode.
\makeatletter
 \begingroup
  \catcode`\_=\active
  \protected\gdef_{\@ifnextchar|\subtextup\sb}
 \endgroup
\def\subtextup|#1|{\sb{\textup{#1}}}
\AtBeginDocument{\catcode`\_=12 \mathcode`\_=32768 }
\makeatother
\ExplSyntaxOff

\DeclareMathOperator{\price}{price}

\DeclareSIUnit\kroner{kr.}

\begin{document}

\begin{align*}
  \MoveEqLeft \price_|total| - \price_|Water park, total|\\
  &= 7 \cdot \price_|hotel, total| + 14 \cdot \price_|adult|(\text{food}) + 14 \cdot \price_|child|(\text{food})\\
  &\hphantom{{}=} - \price_|Water park, total|\\
  &= \SI{2069.00}{\kroner} - \price_|Water park, total|.
\end{align*}

\end{document}

Output

output

Questions

(a) In the second line there is missing a space between the first + and 14. How do I fix this?

(b) In the last line is there too much space between the subscript total and the .? If there is, how do I fix this?

Update

Another question: Is it a difference whether or not there is a blank space between 32768 and } in the code?

I haven't been abel to defect any differences myself when making a few examples.

0

1 Answer 1

11

This is just you'd get from any

Op Binary Ord

sequence. A binary operation symbol following an operator is treated as an ordinary. The same would happen with \sin-x.

There's no reason for definining \price with \DeclareMathOperator, because it's a variable.

\newcommand{\price}{\mathrm{price}}

will give the correct shape and no spacing problem.

enter image description here

0

You must log in to answer this question.

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