1

I’m considering using a backwards R to represent a reflection (mirroing) operation. Although I expected \reflectbox to reflect the geometry of the character, somehow the character becomes replaced by a Cyrillic Ya. \ensuremath{} resolves the issue, although why is a bit mysterious. Even more mysterious is what mechanism substitutes the character when I suppose relsize reverts to math mode.

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{relsize}

\begin{document} \Huge

$R$ $\reflectbox{\ensuremath{R}}$ \\\ $\reflectbox{R}$ $\reflectbox{\protect{R}}$ $\protect{\reflectbox{R}}$

\end{document}

R versus Ya

Can anyone explain what mechanism causes the backwards R to get converted to a Ya?

Bonus points if you can put into concrete terms why using a backward R_p to represent reflection about a plane is a terrible idea.

Thanks!

1 Answers1

2

\reflectbox puts its content in an \hbox for manipulations, and its content is therefore in text mode; what you are getting there is no Cyrillic Ya but a plain reversed R

\documentclass{article}
\usepackage{graphicx}
\begin{document}
R$\reflectbox{R}$
\end{document}

enter image description here

If you want the argument in math mode then you should use something like \reflectbox{$...$}, even within math mode (that's why your version with \ensuremath works).

Here is math version of \reflectbox which scales accordingly to the math style and preserves spacing

\documentclass{article}

\usepackage{graphicx} \usepackage{amsmath}

\makeatletter \newcommand{\mathreflect}[1]{\binrel@{#1}\binrel@@{\mathpalette\math@reflect{#1}}} \newcommand{\math@reflect}[2]{\reflectbox{\m@th$#1#2$}} \makeatother

\begin{document}

$R\mathreflect{R}$ $\scriptstyle P\mathreflect{P}$ $\scriptscriptstyle f\mathreflect{f}$

\end{document}

enter image description here

As David pointed out in comment, \protect isn't doing anything useful here. In a typesetting context like here you are lucky as it expands to \relax and does nothing; in other contexts it might be \string or \noexpand and will likely go awry.

campa
  • 31,130
  • Thank you. Will take some digging to parse those expressions, but looking forwarde to figuring out how it works without the relsize package. I’m clearly still fumbling around a bit; as a novice, it’s easy to start at a high level, where there are plenty of examples, excellent documentation for packages, and lots of answers here. However, it’s been more challenging to self-navigate a layer lower to seen what’s going on below, but not too far below separating the LaTeX from the TeX, etc.

    Your responses helped me better understand how the mode switching works. Thanks again!

    – HoochBlake Sep 06 '22 at 03:31
  • @HoochBlake You can start by reading The mysteries of \mathpalette. The \binrel@/\binrel@@ stuff is quite likely an overkill here. It's descried e.g. here. – campa Sep 07 '22 at 09:29