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 Answers6

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

Gonzalo Medina
  • 505,128
  • 6
    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. – kahen May 02 '12 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).)

Werner
  • 603,163
13

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

Caramdir
  • 89,023
  • 26
  • 255
  • 291
  • And of course for old pi-syntax: $\pi \mathup{\pi}$. Just in case you don't want to copy the uni-code symbol somewhere. – LaRiFaRi Sep 03 '13 at 10:29
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.

kahen
  • 2,165
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}
Peter Grill
  • 223,288
  • 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. – kahen May 02 '12 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} – kahen May 02 '12 at 23:53
  • @kahen: You should post an answer. – Peter Grill May 02 '12 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

yuntaoc
  • 133
  • even more options: look at the chemgreek package (another use case but it lists quite a few packages…) – cgnieder Jul 14 '15 at 22:54