This question has helped me in creating a command for my own package (more a list of commands I defined) to force upright lowercase \pi, and so in my package I have the following code: \renewcommand{\pi}{\text{$\mathup{π}$}}

I don't want to include my entire package here because it's huge. So, as a simpler example, when I run the following code (in LuaLaTeX) it works fine and the pi becomes upright:

\setmathfont{xits-math.otf}    %I use MinionMath-Regular.otf but should work the same

 \verb|\pi| = \pi $\pi$       
 %I put both \pi and $\pi$ here just to show that it can work in and out of math mode.


But, it only shows pi as uppercase this for that particular line! If I go to another place in the document and try $\pi$, it reverts to italicised! Since I'd rather not have to type in $\mathup{\pi}$ or $\mathrm{\pi}$ each time, is there any way to force this command as a default instead?

Below is a screenshot of what I would like as default (left) and what I wish to avoid (right):

upright vs italic pi

  • Hello, Could you please modify the example it such way that it includes the "wrong" pi as well, so that we see what exactly is the problem of yours? – yo' Nov 21 '14 at 12:32
  • @tohecz Good idea, I've added a screenshot. – airatin Nov 21 '14 at 12:32
  • 1
    I think it's still not clear enough. You are not telling us the whole story. Why would it revert to italic? In any case, using \renewcommand\pi{\text{$\mathup{π}$}} seems quite bad. If it's text mode, it should be text mode (just input π), and if it's math mode, then \renewcommand*\pi{\mathrm{π}} should work after putting that redefinition in the correct place (i.e., not inside a group). – Manuel Nov 21 '14 at 14:03
  • 1
    I'm not sure this is a good way to achieve this. Besides, either all Greek letters are upright or none. If you need an upright pi because you want so denote the constant, then give it a name: \newcommand{\cpi}{\mathrm{\pi}} – egreg Nov 21 '14 at 14:07
  • 1
    some package may be setting things up \AtBeginDocument. wrap that around your definition, and put it just before \begin{document} to outwit the other. – barbara beeton Nov 21 '14 at 14:21

I would follow egreg's comment, all italic, or all upright. In case it's a special occasion, then don't redefine \pi but define another command.

\setmainfont{Minion Pro}
  \verb|\pi|:            & $\pi$                 \\
  \verb|π|:              & $π$                   \\
  \verb|π| in text mode: & π \emph{π} \textbf{π} \\

enter image description here

  • According to ISO standards (80000-2:2009), there are certain greek letters that are upright or italic, depending on context. Hence, it would be easier for me this way. Does this solution not redefine \pi though? Or did you mean not redefining \pi is more recommended / preferred more than following this solution? In either case, will try when I get home, thank you. – airatin Nov 21 '14 at 15:59
  • Yes, this does redefine \pi. I added the version with \pi and π so you can see that you still have italic pi available, in case you don't use it as the constant. – Manuel Nov 21 '14 at 16:20
  • And remember that being usable only in math mode is a feature. What is math should be math, and what is text should be text. – Manuel Nov 21 '14 at 16:36
  • I think I remember why I had it in that format; when I'm jotting down notes in class, it's faster for me to write \xnot instead of $\xnot$ (Or \pi vs $\pi$, etc) when it's in a line of text, hence why I allowed that command to be \text{$..$} and I guess I copied that to all my other commands (regardless of whether I would even use them in text or not!). But when I retype my notes properly at home, I do use proper syntax (I.e. $\pi$), it's just so I can compile and make sense of my notes rushedly typed In class when I get home to retype them. – airatin Nov 21 '14 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.