Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This has probably been answered somewhere, but I can't find it from some searching. I sometimes want to write something like Leb for lebesgue measure, and I would like it to be non-italicized, so I usually use \text{Leb} in math mode, but this has the annoyance that it changes inside of an italicized (ams) theorem environment. I usually just hack this and write \text{\emph{Leb}} but clearly this is not ideal.

Is there a replacement for \text that won't inherit this italicizing? Alternatively, is there a more clever hack, in which I can make my macro detect if its going to be italicized and then automatically put in the \emph hack? Clearly the first would be ideal, but the second would also be acceptable.

share|improve this question
2  
Why are you not using \text{\textrm{Leb}} or \text{\textnormal{Leb}}? It always set "Leb" is roman (i.e. normal) font. The \emph hack is kind of ugly. It only works because an \emph inside a \emph is set in roman font again. –  Martin Scharrer Apr 4 '11 at 12:43
    
Ah, see, I did not know about these. I'll give these a try, thanks! –  Otis Apr 4 '11 at 13:02
1  
Actually, the \textrm one does not work for me, but the text normal does. Thanks for the tip! –  Otis Apr 4 '11 at 13:04
    
You are welcome. I added it as an answer now. –  Martin Scharrer Apr 4 '11 at 13:27

2 Answers 2

up vote 5 down vote accepted

You can use \textnormal to switch the font to normal non-italic text independent if the outer text is set in italic or not:

\textnormal{Leb}

Alternatively you can use \mathrm which may make the fonts used more consistent, although this will only work within math mode.

share|improve this answer
1  
would't \mathrm be better than two commands? –  Bruno Le Floch Apr 4 '11 at 13:51
1  
@Bruno: It depends on the application. \text also works in text-mode, and I don't think \mathrm does. –  Martin Scharrer Apr 4 '11 at 13:54
    
thanks for the clarification. I guess the alternative to work in both math and text would be \ensuremath{\mathrm{#1}}, which is no improvement anymore. –  Bruno Le Floch Apr 4 '11 at 16:33
1  
\text switches to the text fonts, which is almost always undesirable for math operators. \mathrm is the better solution here, and it is unimportant whether it also works in text mode since math mode commands shouldn't work in text mode by design. BTW, \textnormal{} is equivalent to \text{\textnormal{}}, so you never need to nest the \text... commands. –  Philipp Apr 4 '11 at 19:57
1  
@Phillip: Thanks. I forgot that \mathrm and \textrm are using different fonts. And you are right about not needing to nest \text... commands. I just played it save. You could post this as an answer or I can modify mine. –  Martin Scharrer Apr 4 '11 at 23:44

I think what you want to do is declare a math operator, which will then be set upright. To your preamble add:

\DeclareMathOperator{\Leb}{Leb}

Then write \Leb in your text. It should be upright, even in theorem environments.

Minimal example:

\documentclass{article}
\usepackage{amsmath,amsthm}
\newtheorem{theorem}{Theorem}
\DeclareMathOperator{\Leb}{Leb}
\begin{document}
\begin{theorem}
$ \Leb  $ is upright and $Ent(\mu|\Leb)$ looks like $Ent(\mu|\nu)$
\end{theorem}
\begin{itemize}
\item $\Leb(x)$
\item $\Leb x$
\item $\mu(x)$
\item $\mu x$
\item $\Leb\! x$
\end{itemize}
\end{document}

As you can see, there is a little difference in the spacing between $\mu x$ and $\Leb x$ which a \! roughly fixes.

share|improve this answer
    
But does this not mess up the spacing afterwards? I would like to write something like $Ent(\mu|\Leb)$ and have the Leb act just like it would with \nu in its place, in terms of spacing. Maybe I just got the wrong idea about how DeclareMathOperator works.. –  Otis Apr 4 '11 at 13:01
    
@Otis why would it mess up the spacing? Things like \mathbin and \mathrel play with spacing, I believe, but this does not (as far as I know.) And if it does, you could always play with the spacing of the macro... –  Seamus Apr 4 '11 at 13:18
1  
\DeclareMathOperator defines an operator (I know: surprise!), and that does indeed have consequences for spacing. However, the spacing rules for math are all about spacing between objects, as summarized by the table on p 170 of the TeXbook (reproduced in section 23.6.1 of TeX by Topic). You will see that the differences in spacing around an operator and an ordinary atom are quite subtle. In particular, there is no difference in the example above, where a close atom follows the symbol. –  Harald Hanche-Olsen Apr 4 '11 at 13:40
    
@Harald does amsmath define something like \DeclareMathOrd that would fix the spacing automatically? –  Seamus Apr 4 '11 at 13:52
1  
No, but you could convert your operator into an ordinary atom by surrounding it by braces. To change the control sequence to make an ordinary operator, use \edef\Leb{{\Leb}}. –  Harald Hanche-Olsen Apr 4 '11 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.