47

On pg. 144 of Kopka and Daily's A Guide to LaTeX, they mention that the symbols $e$, $i$, $d$, and $\pi$ should be displayed upright in math mode (for their usual uses). This is easy to do for $e$, $i$, and $d$: just use \mathrm. However, this does nothing to \pi. How exactly do you generate an upright \pi in math mode?

6
  • 1
    Welcome to TeX.sx! A tip: You can use backticks ` to mark your inline code as I did in my edit. Commented May 2, 2012 at 23:49
  • 6
    Is there a well-known math book that actually does this? Commented Jun 1, 2012 at 0:25
  • 1
    Is MathJax not activated on this website? The inline LaTeX wasn't typetset. I would have thought that inline LaTeX would be functional on, you know, a QA site for TeX . . . (I know it t works on Mathematics StackExchange and Physics StackExchange. Why not here?) Commented Jun 1, 2012 at 1:05
  • 2
    @JonathanGleason: See meta.tex.stackexchange.com/questions/1272/… Commented Jun 1, 2012 at 3:31
  • Related - tex.stackexchange.com/q/145926/128462 Commented Sep 6, 2017 at 12:28

6 Answers 6

35

One option could be to use \uppi from the upgreek package:

\documentclass{article}
\usepackage{upgreek}

\begin{document}

$\uppi$

$\pi$

\end{document}

enter image description here

Here's the upright symbol using the Symbol package option:

\documentclass{article}
\usepackage[Symbol]{upgreek}

\begin{document}

$\uppi$

$\pi$

\end{document}

enter image description here

and now using the Symbolsmallscale package option:

\documentclass{article}
\usepackage[Symbolsmallscale]{upgreek}

\begin{document}

$\uppi$

$\pi$

\end{document}

enter image description here

1
  • 7
    The two options for upright π that upgreek.sty provides don't match Computer Modern too well in my opinion. For example the π above looks far too wide in comparison to the italic greek one. Commented May 2, 2012 at 23:50
18

Without upgreek, babel supports upright Greek characters:

enter image description here

\documentclass{article}
\usepackage[greek,english]{babel}
\begin{document}
\newcommand{\gpi}{\textrm{\greektext p}}
$\gpi \theta$
\end{document}

(Taken from Upright Greek letters in text mode (not upgreek).)

1
  • 7
    Using the textgreek package is easier. Commented May 3, 2012 at 6:33
14

With Xe/LuaLaTeX, unicode-math and a proper OpenType Math font, upright πs (and many other symbols) are built in:

% compile with xelatex or lualatex
\documentclass{article}

\usepackage{unicode-math}
\setmathfont{lmmath-regular.otf}

\begin{document}
$π\ \mathrm{π}$
\end{document}

result

2
  • And of course for old pi-syntax: $\pi \mathup{\pi}$. Just in case you don't want to copy the uni-code symbol somewhere. Commented Sep 3, 2013 at 10:29
  • @LaRiFaRi this no longer works in unicode-math. \mathup{\pi} will look for the italic mathematical pi symbol within the standard roman (non-math) font, which will usually not exist. unicode-math offers \uppi for the upright pi (i.e. the greek non-math letter as far as unicode is concerned) taken from the current math font. In order to get the upright pi in the roman (non-math) font, you must input the pi character in the document, as in the answer. Commented May 5, 2025 at 9:31
11

While upgreek works well for some fonts, it doesn't match perfectly with Computer Modern. Here are some alternatives:

  • Use a different typeface for the document. For example BT Charter from mathdesign(1):

    \usepackage[T1]{fontenc}
    \usepackage[charter,cal=cmcal]{mathdesign}
    
  • Use the text pi that you get when typing Greek text with e.g. babel:

    \usepackage[greek,english]{babel} % english = default
    \usepackage[LGR,T1]{fontenc}
    \usepackage{lmodern,amsmath,xspace}
    \def\PI{\ensuremath{\text{\foreignlanguage{greek}{p}}}\xspace}
    % Similar definitions can be made for the rest of the greek alphabet. 
    % Here's a conversion table:
    % Latin: a b g d e z h j i k l m n x o p r s t u f q y w 
    % Greek: α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω 
    

    While this works it's really ugly and should obviously be done with \DeclareSymbolFont and \DeclareMathSymbol.

  • Same as the above, but using the font bodoni instead. It's a Didone typeface, so it should match pretty well with Computer Modern.

(1): Note that mathdesign has some other design issues such as imperfect kerning, poorly drawn glyphs for blackboard bold letters and \middle\vert usually ends up being too high.

10

From Will Robertson's blog one way is to use the mathpazo. Here is a comparison of the two:

enter image description here

\documentclass{article} 
\usepackage{mathpazo}
\DeclareSymbolFont{euler}{U}{eur}{m}{n}
\DeclareMathSymbol \uppi \mathalpha {euler} {"19}

\begin{document}
    $\pi \quad \uppi$
\end{document}
3
  • It's also possible to use π from the default Greek text font, but I'm not sure which font the symbol is from nor what its number in it is. π from bodoni should also match pretty well with Computer Modern since they are both Didone typefaces. Commented May 2, 2012 at 23:46
  • Expanding on my previous comment on using the Greek text font, one can achieve that like this, but it's a really roundabout (and brittle) way of doing it: \usepackage[greek,english]{babel}\usepackage[LGR,T1]{fontenc}\usepackage{lmodern,amsmath,xspace} \def\PI{\ensuremath{\text{\foreignlanguage{greek}{p}}}\xspace} Commented May 2, 2012 at 23:53
  • @kahen: You should post an answer. Commented May 2, 2012 at 23:55
4

Besides the solutions above, I have recently come across the isomath package and found that page 6 of its manual provides a fairly good summary for available ways to get upright small greek letters.

(One of) the link to the manual itself is: http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/isomath/isomath.pdf

And I take the liberty of taking a screenshot of the relevant page for your convenience:

Extracted from latex package isomath manual v.2012.9.4 page 6

1
  • even more options: look at the chemgreek package (another use case but it lists quite a few packages…) Commented Jul 14, 2015 at 22:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.