To answer what your title ask:
I do not dare to recommend this since \mathrm
doesn't take any arguments, I suspect something bad happens.
Both examples below prints hello world
\documentclass{article}
\begin{document}
\newif\ifMathrm
\newcommand\mathrmNew[1]{\Mathrmtrue\mathrm{#1}\Mathrmfalse}
\newcommand\hello{\ifMathrm world\else hello\fi}
\[ \hello~\mathrm{\hello} \]
\end{document}
It would be a little bit better to make \mathrmNew
that toggles a flag. This is better because it doesn't execute the if-statements everytime \mathrm
is called. Like this:
\documentclass{article}
\begin{document}
\newif\ifMathrm
\newcommand{\mathrmNew}[1]{\Mathrmtrue\mathrm{#1}\Mathrmfalse}
\newcommand{\hello}{\ifMathrm world\else hello\fi}
\[ \hello~\mathrmNew{\hello} \]
\end{document}
\III
in math mode not inside\mathrm
?\III
symbol both in italic and in upright shape: did you consider inputting it as$\mathit{\III}$
(and not just as$\III$
) when you want it to appear in italic, and as$\mathrm{\III}$
when you want it to be upright? I’m saying this because I suspect that you are tampering with the space only in order to compensate for the fact that$\III$
uses wider characters than$\mathit{\III}$
.