This is follow-up question to this one. My aim is to let greek letters behave the same like normal latin letters, when it comes to get them upright. At the moment I'm using \mathrm
to get letters upright in math mode.
So \mathrm{\delta d}
should return an upright d and an upright delta. A custom command \upright
would be an option too, but I wouldn't know where to start. The important part is, that I could use that command for both, greek and latin letters, equally - without additional commands like \deltaup
or \updelta
. The reason is that I need to work with different classes, different fonts and even different compilers, so I need to get a most generic solution. Using fontspec/unicode-math (which would solve the problem, is not an option).
From my previous question I learned by Ulrike Fischer's answer, that there would be no way around using \deltaup
for my case. And she offered the neat solution:
\let\deltait\delta\renewcommand\delta{\ifnum\fam=0 \deltaup\else \deltait\fi}
In case some of my colleagues uses the upgreek package and \updelta
I wrapped an if condition around:
\makeatletter
\ifcsname deltaup\endcsname%
\let\deltait\delta\renewcommand\delta{\ifnum\fam=0 \deltaup\else \deltait\fi}
\else
\ifcsname updelta\endcsname
\let\deltait\delta\renewcommand\delta{\ifnum\fam=0 \updelta\else \delta\fi}
\fi
\fi%
Now I wonder whether I could put this into a loop to deal with all lowercase greek letters.
I thought about a list with all letters, but I don't know how to get dynamic input arguments in cases like \let\deltait\delta
.
Of course I could just write the same lines for every letter, but maybe another font than pxfonts later requires another solution and always redefining the whole alphabet seems cumbersome.
Furthermore jfbu mentioned in his answer/comments that using \mathrm
wouldn't be a good option at all, as I'm changing the font family, which I shouldn't.
MWE
\documentclass{article}
\usepackage[utf8x]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage{pxfonts}
\usepackage{siunitx}
%\usepackage{isomath}
%\usepackage{upgreek}
\usepackage[ISO]{pxgreeks}
\makeatletter
\ifcsname deltaup\endcsname%
\let\deltait\delta\renewcommand\delta{\ifnum\fam=0 \deltaup\else \deltait\fi}
\else
\ifcsname updelta\endcsname
\let\deltait\delta\renewcommand\delta{\ifnum\fam=0 \updelta\else \deltait\fi}
\fi
\fi%
\begin{document}
\begin{equation}
\Phi_{\mathrm{\delta}} = \SI{42}{\micro\Omega} \cdot \delta_{\mathrm{\Phi}}
\end{equation}
\begin{equation}
P_{\mathrm{d}} = \SI{42}{\nano\ampere} \cdot d_{\mathrm{P}}
\end{equation}
\end{document}
\mathXX
command but it works.\mathbf{a\int \delta b}
will make the a and b bold, but "ignore" the\int
and the\delta
. And please: Don't use\Omega
for\ohm
, that's not semantic.\mathrm
was not ideal, it was simply to recall that its meaning from LaTeX NFSS is to switch to some font, not to set attributes. This of course is explained by the prevailing fonts at that time with their at most256
glyph slots.