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.
-
1Do you want all math in upright font or only this specific expression?– samcarter_is_at_topanswers.xyzMar 16, 2019 at 20:03
-
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers.– MenschJun 12, 2019 at 15:30
3 Answers
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.
-
-
1
-
@Gina: Just out of curiosity: must all your capital letters in formulæ be in uprightshape?– BernardMar 16, 2019 at 19:40
-
1@Gina You are welcome. Please consider to upvote one or both answers and accept one of the two. Mar 16, 2019 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
.