2

The option "origin=lb" in the macro \rotatebox which comes frome the package graphicx, means the object will rotates by its left-hand bottom. So the "typeset-1 & typeset-2" in the following code

\documentclass{article}
\usepackage{fancyhdr,graphicx,tcolorbox}
\begin{document}
\pagestyle{fancy}
\noindent
\parindent=0pt
\makebox[0pt][l]{some text}% typeset-1
\rotatebox[origin=lb]{90}{some text}\\[3em]% typeset-2

\rotatebox{0}{% typeset-3
  \begin{tcolorbox}[width=0.7\textwidth,height=6em]
    the left side of this box alligns well with the left end of the headrule.
  \end{tcolorbox}
}\\
%
\rotatebox[origin=lb]{90}{% typeset-4
  \begin{tcolorbox}[width=0.7\textwidth,height=6em]
    As the option "origin=lb" is used, the right side of this rotated box should align with the left end of the headrule, but it does not.
  \end{tcolorbox}
}
\end{document}

should be like this: enter image description here but get this: enter image description here When the object comes from tcolorbox(see typeset-3 & typeset-4 in the above code), they have the same problem. Is this a problem of \rotatebox or other? How to get a typeset effect like the first figure?

3
  • If you want this kind of positioning have a look at the xcoffins package.
    – TeXnician
    May 23, 2018 at 6:49
  • 1
    The width of the rotated box is taken into account. So it does not overlay previous text or run into the left margin. You have to hide the width of the rotated box: \makebox[0pt][r]{\rotatebox[origin=lb]{90}{some text}} or the height of the contents: \rotatebox[origin=lb]{90}{\smash{some text}}. Note that the results would be different if there would be a descender like in "my text".
    – esdd
    May 23, 2018 at 8:55
  • @ esdd very simple and perfect solution! Anywhere finds the working principal of the \smash?
    – lyl
    May 24, 2018 at 2:59

1 Answer 1

2

The width of the rotated box is taken into account. So it does not overlay previous text or run into the left margin. You have to hide the width of the rotated box:

\makebox[0pt][r]{\rotatebox[origin=lb]{90}{some text}}

or the height of the contents:

\rotatebox[origin=lb]{90}{\smash{some text}}. 

Note that the results of these suggestions would be different if there is a descender like in "my text".

Example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{parskip}% <- parskip instead parindent, only for the example
%\usepackage{showframe}% <- to show the pagelayout, only for the example
\begin{document}

\makebox[0pt][l]{some text}% typeset-1
\rotatebox[origin=lb]{90}{some text}\\[3em]% typeset-2

\makebox[0pt][l]{some text}% typeset-1
\makebox[0pt][r]{\rotatebox[origin=lb]{90}{some text}}% typeset-2

\makebox[0pt][l]{some text}% typeset-1
\rotatebox[origin=lb]{90}{\smash{some text}}% typeset-2

\bigskip
\noindent
\makebox[0pt][l]{some text}% typeset-1
\makebox[0pt][r]{\rotatebox[origin=lb]{90}{my text}}% typeset-2

\makebox[0pt][l]{some text}% typeset-1
\rotatebox[origin=lb]{90}{\smash{my text}}% typeset-2

\end{document}

Result:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .