0% found this document useful (0 votes)
486 views2 pages

LATEX: Hyphens in Math Mode

This document discusses proper ways to typeset hyphens in LaTeX math mode. It identifies two bad approaches: directly typing hyphens and using mboxes. It recommends two good approaches: defining a new math character or using the \operatorname command from the amsmath package. No matter the approach, the document suggests defining commands for operators to avoid lengthy key sequences and ensure consistent typesetting.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
486 views2 pages

LATEX: Hyphens in Math Mode

This document discusses proper ways to typeset hyphens in LaTeX math mode. It identifies two bad approaches: directly typing hyphens and using mboxes. It recommends two good approaches: defining a new math character or using the \operatorname command from the amsmath package. No matter the approach, the document suggests defining commands for operators to avoid lengthy key sequences and ensure consistent typesetting.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A L TEX: Hyphens in Math Mode Gernot Salzer, salzer@logic.

at 9 December 2008, updated 1 June 2009


Abstract
A Hyphens are sometimes necessary in L TEXs math mode to structure long variable or function names. We present four ways to typeset them, two bad ones and two good ones. This discussion seems to be necessary since the knowledge about how to do it right is not wide-spread.

Bad: typing hyphens directly


In math mode, the hyphen symbol is typeset as minus sign, which is too long for an ordinary hyphen. Moreover, the spacing is wrong. $\mathit{non-unique}$ $\mathrm{non-unique}$ $A_{\mathit{non-unique}}$ \boldmath $A_{\mathit{non-unique}}$ non unique non unique Anonunique Anonunique

Bad: using mboxes


Putting the hyphen into an mbox improves the situation: the length of the hyphen as well as the spacing is correct. However, size and font dont change with the surrounding math. $\mathit{non\mbox{-}unique}$ $\mbox{non-unique}$ $\mathrm{non\mbox{-}unique}$ $A_{\mathit{non\mbox{-}unique}}$ \boldmath$A_{\mbox{non-unique}}$ non-unique non-unique non-unique Anon -unique Anon-unique

Good: dening a mathchar


To obtain a proper hyphen that changes with the surrounding math we dene a new math character:

\mathchardef\mhyphen="2D $\mathit{non\mhyphen unique}$ $\mathrm{non\mhyphen unique}$ $A_{\mathit{non\mhyphen unique}}$ \boldmath$A_{\mathit{non\mhyphen unique}}$ non-unique non-unique Anon-unique Anon-unique

Good: dening an amsmath operator


The amsmath package provides the command \operatorname, which typesets hyphens correctly and also changes their size and font. The only restriction is that you are bound to the current operator font, usually upright. As a general rule, names denoting entities with a xed meaning are typeset in an upright font, whereas variables are typeset in an italic font. \usepackage{amsmath} $\operatorname{non-unique}$ $A_{\operatorname{non-unique}}}$ \boldmath$A_{\operatorname{non-unique}}}$ non-unique Anon-unique Anon-unique

Dening appropriate commands


No matter which method you choose, it is a good idea to dene commands for your operators. This avoids keying in lengthy character sequences and achieves consistent typesetting. \mathchardef\mhyphen="2D \newcommand\nuniq{\mathit{non\mhyphen unique}} $\nuniq$, \boldmath$A_\nuniq$ non-unique, Anon-unique \usepackage{amsmath} \newcommand\nuniq{{\operatorname{non-unique}}} $\nuniq$, \boldmath$A_\nuniq$ non-unique, Anon-unique Note the use of extra braces around \operatorname, which is necessary to make \nuniq work in subscripts and the like.

You might also like