# A short hyphen in a math formula

In a LyX math formula, I want to write something like "r-number". However, the usual dash looks too long (like a minus sign). I am looking for a short, possibly upper hyphen. I couldn't find it in the lists of symbols in the bottom toolbar, and I also don't know how to search for symbols online If you can give me a tip, how to find a symbol that I need, this will be very useful.

• Can't we use \text{r-number} with package amstext loaded? I haven't used LyX though. Also check the symbols list at tex.ac.uk/tex-archive/info/symbols/comprehensive/symbols-a4.pdf. – Jagath Jul 9 '13 at 7:01
• Here's what I use for "F-an" (meaning F-analytic) \text{$F\!\mbox{-}\mathrm{an}$} – Laurent Berger Jul 9 '13 at 7:27
• The right way to type this is $r$-number: only the $r$ is part of the formula; or else do you need the whole "r-number" inside a formula? – egreg Jul 9 '13 at 9:18
• I need all of it inside the formula. It is the name of a function. – Erel Segal-Halevi Jul 9 '13 at 9:28
• @LaurentBerger, that seems like an awful lot of work to subvert LaTeX's understanding of what is math and what is text. Why not \text{$F$-an}? – LSpice Jun 18 '15 at 4:53

Here are three suggestions. The first is my own, and the second and third are adapted from (http://www.logic.at/staff/salzer/etc/mhyphen/). Note that the first and second both output "math italic" text, but the third outputs "upright" text.

\documentclass{article}
\begin{document}
\newcommand\rnumber{\mathop{\mbox{$r$-$\mathit{number}$}}}
$\rnumber(5) = 120$
\end{document}


\documentclass{article}
\usepackage{amsmath}
\mathchardef\mhyphen="2D % Define a "math hyphen"
\begin{document}
\newcommand\rnumber{\mathop{r\mhyphen number}}
$\rnumber(5) = 120$
\end{document}


\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newcommand\rnumber{\operatorname{r-number}}
$\rnumber(5) = 120$
\end{document}


LyX users should put the definitions (\usepackage, \newcommand, \mathchardef, etc.) in Document -> Settings -> LaTeX Preamble, and the usage (e.g. \rnumber(5) = 120) inside math-mode (Ctrl+M).

• Thank you! I edited to add a note for LyX users (such as myself). – Erel Segal-Halevi Jul 9 '13 at 17:33
• what is "2D? Is that the character definition for hyphen? if so, where can I find others? – nlucaroni Nov 8 '13 at 19:39
• @nlucaroni, it is just the ASCII code in hexadecimal: see en.m.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart – LSpice Jun 18 '15 at 4:57
• You should move the \newcommands to the document preamble (before \begin{document}). – Schweinebacke Aug 13 '17 at 10:32

I think this is simpler.

$r{\text -}number(5)=120$


My first shot would be \DeclareMathOperator; but it depends on the meaning of "r": if it represents a math variable it should be in italics. I'll show both possibilities, take your pick.

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator{\rnumberA}{r-number}
\DeclareMathOperator{\rnumberB}{\mathnormal{r}-number}

\begin{document}

$\rnumberA(2)$

$\rnumberB(2)$

\end{document}


• It seems that this solution does not work to typeset an r'-number: the ' becomes an apostrophe, rather than a prime. – Bubaya Oct 28 '20 at 11:40
• @Bubaya You can use r^{\prime}. – egreg Oct 28 '20 at 11:46
• Sure, but how about \operatorname{\mathnormal{r^2}-number}? – Bubaya Oct 28 '20 at 12:04
• @Bubaya \mathnormal{r}^2 – egreg Oct 28 '20 at 12:17
• Sorry, my comment was apparently too short to make my point. If I write \newcommand{\Mod}[1]{\operatorname{\mathnormal{#1}-Mod}}, things like \Mod{A_2} fail. – Bubaya Oct 28 '20 at 12:19

To define a hyphen for use as part of a hyphenated name in a macro, I used the command \def\mymathhyphen{{\hbox{-}}}. This gives the usual en-dash.

Yet another way to create a dash is to use a strike-out through a space.

It creates a slightly longer one than given in the answer by Sam Buss, which is what I needed. One could define the macro by

\usepackage[normalem]{ulem}
\newcommand{\mydash}{\hbox{\sout{ }}}