37

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.

  • 3
    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
  • 2
    @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
23

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} 

enter image description here

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

enter image description here

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

enter image description here

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).

|improve this answer|||||
  • 1
    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
17

I think this is simpler.

$r{\text -}number(5)=120$
|improve this answer|||||
14

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}

enter image description here

|improve this answer|||||
8

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.

|improve this answer|||||
2

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{ }}} 
|improve this answer|||||

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.