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.

I read many things about people wanting math mode in sans-serif font and doing crazy things with packages and options to get that, but I did not find anything that would simply make my math mode font non-italic.

Is there an (easy) way to set math mode font to be non-italic?

And is there a way to do that globally for the whole document?

share|improve this question
add comment

5 Answers

up vote 13 down vote accepted

On a case-by-case basis, it is possible to typeset text within math mode using \textrm{...} or \mathrm{...}, the latter being used predominantly for typesetting units or symbols and not pure text (since it gobbles spaces that are not escaped). \mbox{...} is another alternative to \textrm{...}, since it resets its contents to text mode by default. Here are some examples:

enter image description here

\documentclass{article}
\begin{document}
Here is a formula: $x=\exp(\log \mathrm{x})$

Here is another: $\sin^2 t+\cos^2 t = \textrm{famous identity}$
\end{document}​

The above font changes do not work that well in general, since switching to a different font when using sub- and superscripts, say, does not always scale as expected. There are ways around it though. For example, using \text{...} from the amstext package (automatically loaded by amsmath - see the AMS package dependencies), which switches to the appropriate font size via \mathchoice:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
% amsmath loads the amstext package by default
\begin{document}
Here is a formula: $x=y^{abc}$

Here it is again: $x=y^{\mbox{abc}}$

Compare that to: $x=y^{\text{abc}}$
\end{document}​
share|improve this answer
add comment

The results are not always perfect, but mathastext is what you're looking for, when you want to set globally the math font to upright (or to use another completely different font, check the documentation):

\documentclass{article}
\usepackage[LGRgreek]{mathastext}

\begin{document}
Here is a formula: $x=\exp(\log x)$

Here is another: $\sin^2 t+\cos^2 t = 1$

What about Greek? $\alpha+\beta$
\end{document}

enter image description here

Don't tell anybody that I recommended it. :) Indeed I strongly advise not to do evil things like printing all math upright. :)

share|improve this answer
    
So your advise is typing \mbox{...} before every math line? –  cebe Dec 28 '11 at 23:37
3  
@cebe No, my advise is to use italics for math as typographers have done for centuries. If you really want to use roman letters for math, then mathastext is the right tool. –  egreg Dec 28 '11 at 23:41
1  
Reluctantly I'm casting a vote for this answer:-) The mathastext package lets you cheat on proper math typesetting but sometimes it looks nice. –  Marc van Dongen Dec 28 '11 at 23:52
2  
+1 for the "evil" tag. Bringhurst is weeping. –  Brent.Longborough Dec 29 '11 at 9:54
add comment

Probably not what you are looking for, but you could use the Euler math font which is an upright math font (non-italic).

\documentclass{article}
\usepackage[osf,sc]{mathpazo}
\usepackage{eulervm}
\begin{document}
This is some text in Palatino with an inline equation $f(x)=\cos(x^2)$
followed by an equation:
\begin{equation}
  \int_{0}^{1}\frac{1}{1 + x^2}\mathrm{d}{x}
\end{equation}
\end{document}

Just don't use them with Computer Modern. (My example here uses Palatino for the text font.)

Sample output

share|improve this answer
    
So far the only asthetic solution for upright maths :-) –  Daniel Sep 25 '13 at 10:48
add comment

Also if you're writing the same thing over, like units, I just created a new command and used it every time:

\newcommand{\inch}{\ensuremath{\,\textrm{in.}}}

This returns "in." without italics, and a space after the number. :)

\begin{equation}
\frac{19\inch-2.75\inch}{2} + 0.54 \inch = 8.125\inch + 0.54\inch = 8.665\inch
\label{eq:outeredgemodel}
\end{equation}

becomes:

enter image description here

share|improve this answer
add comment

Some packages (MinionPro, mathdesign, fourier, kpfonts) have an option "frenchmath” (the exact name depends on the package), which typesets uppercase roman letters and all greek letters upright, and takes care of the metrics.

share|improve this answer
add comment

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.