# Math equation in non italic font

I am trying to write the following $T_E$ but it appears in italic font. I tried also $\text{T_E}$ but LaTeX gives me error.

Depending of if you are actually writing math or text:

 \documentclass{article}

\begin{document}
$\mathrm{T}_{\mathrm{E}}$ or T\textsubscript{E}

\end{document}


The following examples illustrates several possible solutions.

\documentclass{scrartcl}
\usepackage{amsmath}

\newcommand{\testline}{Text $\mathrm{T}_\mathrm{E}$ or $\text{T}_\text{E}$ or $\textup{T}_\textup{E}$ or T\textsubscript E}

\begin{document}

\testline

\itshape\testline

\sffamily\upshape\testline

\itshape\testline

\rmfamily\upshape\bfseries%as before but bold

\testline

\itshape\testline

\sffamily\upshape\testline

\itshape\testline

\end{document}


Observe that some of them adopt the style and font of the text.

• I'd rather use \mathrm – Bernard Mar 16 '19 at 19:38
• It works!! Thanks a lot :) – Gina Mar 16 '19 at 19:39
• @Gina: Just out of curiosity: must all your capital letters in formulæ be in uprightshape? – Bernard Mar 16 '19 at 19:40
• @Gina You are welcome. Please consider to upvote one or both answers and accept one of the two. – CampanIgnis Mar 16 '19 at 19:57

## With the Modern Toolchain

With the unicode-math package (which I personally recommend, although not everyone agrees), \mathrm is still supported for backwards compatibility, but so is the synonym \mathup, and the closely-related \symup.

If you use \symup, you can specify a different upright font from the regular text font, and from operator names like log, sin and lim. My go-to example is setting Euler’s identity in ISO style, that is, with symbolic constants set in an upright font, with the constants e, π and i in Euler and everything else in Palatino. It’s a good example of why you might want a different upright font for math variables.

\documentclass[varwidth, preview]{standalone}

\usepackage{mathtools}
\usepackage[math-style=ISO]{unicode-math}

\setmainfont{TeX Gyre Pagella}
\defaultfontfeatures{Scale=MatchLowercase}

\setmathfont{Asana Math}
\setmathfont[range={up/{Latin,latin,Greek,greek},
bfup/{Latin,latin,Greek,greek}},
script-features={}, sscript-features={}
]{Neo Euler}

\newcommand\upe{\symup{e}}
\newcommand\upi{\symup{i}}

\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}


(If you want to do something like this with the default font, you can try either Latin Modern Roman Unslanted or CMU Serif Upright Italic. Here’s a sample of the latter:

\documentclass[varwidth, preview]{standalone}

\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=up/{Latin,latin,Greek,greek}]{CMU Serif Upright Italic}

\begin{document}
\begin{align*}
\symup{e}^{\symup{i} x} &= \cos{x} + \symup{i} \sin{x} \\
\symup{e}^{\symup{i \pi}} + 1 &= 0
\end{align*}
\end{document}


The \symup command is intended to be used this way. The \mathrm and \mathup commands are more for words in equations, like naming variables TIME and ENERGY. Another good alternative for whole words is to use \operatorname from amsmath. This formats the text like \log or \sin, that is, inserts spacing like 2 log x rather than 2logx.

There are similarly \mathtt and \mathsfup for monospaced and sans-serif letters.

You could also, for example, do \newcommand\TIME{\mathop{\mbox{\scshape time}}} to get TIME in small caps, with the spacing of an operator.

You can make upright math variables the default by loading the package with \usepackage[math-style=upright]{unicode-math}.

## With the Legacy Toolchain

The eulerpx package implements the popular combination of Euler math variables and Palatino text, along with symbols from newpxmath. If you want upright letters in PDFLaTeX, this in my opinion is the most attractive package for them.

The cfr-lm package makes upright italics easily available; with this package, you could write \DeclareRobusTCommand\mathui[1]{\mbox{\uishape #1}} to get upright italics. The example I gave earlier with \scshape for small-caps would work as well.

To format a variable name in the default font, \operatorname from amsmath is a good option.

For a more complicated use case, there are \DeclareMathAlphabet and \DeclareMathSymbol.