15

I use libertine and newtxmath font packages, they provide upright greek letters. However, there is no way to conveniently swith between italic and upright greek letters. I need a command, simillar to what is discussed here, to change normal greek letters to upright bold symbols.

None of the commands \mathrm, \mathbf, \boldsymbol or \bm makes\theta to appear as \uptheta. Moreover, isomath package does not work with the encoding and its typeface is not desired. I don't want to globally switch to upright greek letters or change the font shape.

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[type1]{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{bm} 

\begin{document}
What I get: $\theta \bm{\theta} \mathrm{\theta} \bm{\mathrm{\theta}}$

What I want: $\theta \bm{\theta} \uptheta \bm{\uptheta}$ 
\end{document}

--- Partial Solution ---

I found that a new upgreek command may be defined to replace all greek letter macros (e.g. \theta) with their upside variants (e.g. \uptheta) in its argument. Following example does it for three greek letters. The scope of the command is local, so both variants can be used in a single equation.

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[type1]{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{bm} 

\newcommand{\upgreek}[1]{{
\renewcommand{\beta}{\upbeta}
\renewcommand{\theta}{\uptheta}
\renewcommand{\zeta}{\upzeta}
#1
}}

\begin{document}
$\upgreek{\theta} \bm{\upgreek{\theta}} \theta \bm{\theta}$ 
\end{document}

Questions:

  • Is it safe to patch \mathrm to run \upgreek on its argument?
Aydin
  • 1,983
  • Could l2tabu help you? Section 2.3.6 Typesetting upright greek letters? I never used upgreek letters before so this was just a wild guess – patrickvogt Apr 18 '13 at 12:14
  • This may be of interest. – jub0bs Apr 18 '13 at 12:16
  • @patrick Thanks. It suggest using 'upgreek', which does not help to switch between upright and italic greek letter. – Aydin Apr 18 '13 at 12:23
  • @Jubobs I ckecked it. isomath is not working with libertine, and globally forcing greek letters to upright form is not wanted. I need \mathrm or any other command to modify \theta to appear as \uptheta. – Aydin Apr 18 '13 at 12:27
  • I believe the correct command you want is \mathup, not \mathrm. I can't compile the MWE for come reason so I can't offer much help. How about loading amsmath and try \operatorname{\theta}? – Mobius Pizza Apr 18 '13 at 13:47
  • @MobiusPizza Which package defines \mathup ? \operatorname calls \mathrm. Did you try them yourself ?! – Aydin Apr 18 '13 at 14:05
  • @Aydin my bad, mathup is something related to unicode-math in XeTeX or LuaTex – Mobius Pizza Apr 18 '13 at 14:49

2 Answers2

16

You might want to file a feature request to the developer of newtxmath; in the meantime you can change the definitions of the Greek lowercase letters.

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[type1]{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{bm} 

\makeatletter
\re@DeclareMathSymbol{\alpha}{\mathord}{lettersA}{11}
\re@DeclareMathSymbol{\beta}{\mathord}{lettersA}{12}
\re@DeclareMathSymbol{\gamma}{\mathord}{lettersA}{13}
\re@DeclareMathSymbol{\delta}{\mathord}{lettersA}{14}
\re@DeclareMathSymbol{\epsilon}{\mathord}{lettersA}{15}
\re@DeclareMathSymbol{\zeta}{\mathord}{lettersA}{16}
\re@DeclareMathSymbol{\eta}{\mathord}{lettersA}{17}
\re@DeclareMathSymbol{\theta}{\mathord}{lettersA}{18}
\re@DeclareMathSymbol{\iota}{\mathord}{lettersA}{19}
\re@DeclareMathSymbol{\kappa}{\mathord}{lettersA}{20}
\re@DeclareMathSymbol{\lambda}{\mathord}{lettersA}{21}
\re@DeclareMathSymbol{\mu}{\mathord}{lettersA}{22}
\re@DeclareMathSymbol{\nu}{\mathord}{lettersA}{23}
\iftx@altnu
  \re@DeclareMathSymbol{\nu}{\mathord}{lettersA}{40}
\fi
\re@DeclareMathSymbol{\xi}{\mathord}{lettersA}{24}
\re@DeclareMathSymbol{\pi}{\mathord}{lettersA}{25}
\re@DeclareMathSymbol{\rho}{\mathord}{lettersA}{26}
\re@DeclareMathSymbol{\sigma}{\mathord}{lettersA}{27}
\re@DeclareMathSymbol{\tau}{\mathord}{lettersA}{28}
\re@DeclareMathSymbol{\upsilon}{\mathord}{lettersA}{29}
\re@DeclareMathSymbol{\phi}{\mathord}{lettersA}{30}
\re@DeclareMathSymbol{\chi}{\mathord}{lettersA}{31}
\re@DeclareMathSymbol{\psi}{\mathord}{lettersA}{32}
\re@DeclareMathSymbol{\omega}{\mathord}{lettersA}{33}
\re@DeclareMathSymbol{\varepsilon}{\mathord}{lettersA}{34}
\re@DeclareMathSymbol{\vartheta}{\mathord}{lettersA}{35}
\re@DeclareMathSymbol{\varpi}{\mathord}{lettersA}{36}
\re@DeclareMathSymbol{\varrho}{\mathord}{lettersA}{37}
\re@DeclareMathSymbol{\varsigma}{\mathord}{lettersA}{38}
\re@DeclareMathSymbol{\varphi}{\mathord}{lettersA}{39}
\makeatother

\begin{document}
What I get: $\theta \bm{\theta}$

What I want: $\uptheta \bm{\uptheta}$ 
\end{document}

Note that \mathbf{\theta} won't do any good, only Latin letters are affected by \mathbf.

enter image description here


You can also define \mathup and \mathbfup:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[type1]{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{bm}
\DeclareRobustCommand{\mathup}[1]{\begingroup\changegreek\mathrm{#1}\endgroup}
\DeclareRobustCommand{\mathbfup}[1]{\begingroup\changegreekbf\mathbf{#1}\endgroup}

\makeatletter
\def\changegreek{\@for\next:={%
  alpha,beta,gamma,delta,epsilon,zeta,eta,theta,kappa,lambda,mu,nu,xi,pi,rho,sigma,%
  tau,upsilon,phi,chi,psi,omega,varepsilon,vartheta,varpi,varrho,varsigma,varphi}%
  \do{\expandafter\let\csname\next\expandafter\endcsname\csname\next up\endcsname}}
\def\changegreekbf{\@for\next:={%
  alpha,beta,gamma,delta,epsilon,zeta,eta,theta,kappa,lambda,mu,nu,xi,pi,rho,sigma,%
  tau,upsilon,phi,chi,psi,omega,varepsilon,vartheta,varpi,varrho,varsigma,varphi}%
  \do{\expandafter\def\csname\next\expandafter\endcsname\expandafter{%
    \expandafter\bm\expandafter{\csname\next up\endcsname}}}}
\makeatother

\begin{document}
$\mathup{d}\mathup{\theta}d\theta$

$\mathbfup{d}\mathbfup{\theta}\bm{d}\bm{\theta}$
\end{document}

enter image description here

egreg
  • 1,121,712
  • Thankx. How can I make this symbol declarations local? I don't want to change the appearance of $\theta$, but $\mathrm{\theta}$. I edited the MWE to be more clear. – Aydin Apr 22 '13 at 10:37
  • 1
    @Aydin Sorry, but I don't understand: \mathrm doesn't work with Greek letters. – egreg Apr 22 '13 at 10:42
  • 1
    Yes it doesn't and I want it to work. isomath makes it working for greek letters but it has other problems. I can use any other command instead of \mathrm, e.g., \upright{\theta}. What I need is a solution to locally change the appereance of greek letters to be upright, but not globally. One idea is to redefine \mathrm to locally replace any command like \theta with \uptheta. – Aydin Apr 22 '13 at 11:02
  • I modified the question and now it reflects my idea for a solution. – Aydin Apr 22 '13 at 13:40
  • @Aydin They're both the same – User 17670 Apr 22 '13 at 15:08
  • @egreg Thank you very much. mathup and mathbfup are exactly what I need. They work smoothly and can be included in other macros. I just edited your \mathbfup commmand above to use \bm{\mathrm{}} instead of \mathbf{}. – Aydin Apr 25 '13 at 10:55
  • @Aydin Why should \bm{\mathrm{...} be necessary instead of \mathbf? If you look closely, \mathbfup changes the meaning of the Greek letters to give \bm{\alpha} and so on. – egreg Apr 25 '13 at 10:58
  • @egreg \bm\mathrm{} works on all letters and fonts. I need \mathbfup to make every math upright and bold not just greek letters. Otherwise, I have to include it inside another \bm{\mathrm{} that would be absrud. – Aydin Apr 25 '13 at 11:01
  • @egreg, And, why do you need \changegreekbf instead of \changegreek\bm that works for me? – Aydin Apr 25 '13 at 11:15
  • @Aydin Sorry, but I don't understand: do the macros work? I think so. – egreg Apr 25 '13 at 12:08
  • @egreg, your macros work. But if you try \mathbfup{h\theta} you will get an upright theta with a slanted h, at least in my document. So, you need to do the small change. Moreover, I think you can reuse \changegreek instead of defining a separate bold version, that is however not imprtant. – Aydin Apr 26 '13 at 14:05
  • @Aydin I get upright "h" and "theta". Doing \bm on multiletter input is not guaranteed to give good results, so I prefer keeping this version. – egreg Apr 26 '13 at 14:15
  • @egreg, Ok.... The purpose of this thing for me, is to define new macros \vect and \mat to convert all vector and matrix names into upright bold symbols in text or math. They can be greek or latin letters. I keep \bm\mathrm as it's the way that works for me. Thank you very much. – Aydin Apr 29 '13 at 07:06
5

with xelatex or lualatex you can choose the french style for upright greek letters and have also commands for the bold one:

\documentclass{report}
\usepackage[math-style=french]{unicode-math}
\usepackage{libertine}
\setmathfont{XITS Math}

\begin{document}
What I get: $\theta \mbftheta \alpha \mbfalpha\mbftheta$ \\

What I want: $\theta \alpha\beta \mbfmu$ 
\end{document}

enter image description here

Moriambar
  • 11,466
  • 1
    I do not want to globally switch to upright greek letters. What is needed, is a solution to temporally switch between upright and slanted greek letters. – Aydin Apr 22 '13 at 10:31
  • 1
    you can define an own math version upgreek. Then you can switch between upright and italic greek with \mathversion{...} –  Apr 22 '13 at 11:12