[Tex/LaTex] Rotating a letter

charactersrotating

I'd like to rotate a letter such as, say B, to show its reflection or inversion symmetry, or even at an arbitrary angle clockwise or counter-clockwise. Is this possible using commands without drawing a picture? Can I use \usepackage{rotating} out of a table? I used the code \begin{rotate}{180}B\end{rotate}. That puts B rotated as a subscript to the line. Any idea how to make it in-line aligned with other charcters?

Best Answer

With the graphicx package, you can do it as follows: \rotatebox[origin=c]{180}{B}

This rotates around the center of the letter. You can also rotate around other points: \rotatebox[origin=tr]{180}{B} will rotate around the top right of the box. See page 8 of this document for all the relevant options.

Following from what egreg pointed out, you may need a \raisebox to have the resulting this sit on the baseline:

\documentclass{scrartcl}
\usepackage{graphicx}
\newcommand\testletter[1]{
  \begin{tabular}{rl}
    Rotate: & #1\rotatebox{180}{#1}\hspace{-1em}\rule{1em}{0.5pt}\\
    Rotate and raise: & #1\raisebox{\depth}{\rotatebox{180}{#1}}\hspace{-1em}\rule{1em}{0.5pt} \\
    Rotate around centre: & #1\rotatebox[origin=c]{180}{#1}\hspace{-1em}\rule{1em}{0.5pt} \\
    Rotate around centre and raise: & #1\raisebox{\depth}{\rotatebox[origin=c]{180}{#1}}\hspace{-1em}\rule{1em}{0.5pt} \\
    Rotate (120): & #1\rotatebox{120}{#1}\hspace{-1em}\rule{1em}{0.5pt} \\
    Rotate (120) around centre: & #1\rotatebox[origin=c]{120}{#1}\hspace{-1em}\rule{1em}{0.5pt} \\
    Rotate (120) and raise: & #1\raisebox{\depth}{\rotatebox{120}{#1}}\hspace{-1em}\rule{1em}{0.5pt} \\
    Rotate (120) around centre and raise: & #1\raisebox{\depth}{\rotatebox[origin=c]{120}{#1}}\hspace{-1em}\rule{1em}{0.5pt}
  \end{tabular}
}
\begin{document}
\testletter{B}

\testletter{g}

\testletter{f}
\end{document}

The rule is just to show where the baseline is.

differences again

As you can see, the raisebox only makes a difference for letters with descenders (g,y,j etc). And which one you prefer is a matter of taste. (Also, doing both rotate about centre and raise seems otiose. Doing one or the other suffices, depending on which result you want...

Related Question