\rotatebox{} without horizontal translation

alignmentdiagramspicture-moderotating

I would like to rotate an element inside of a picture environment about a specified point. I tried using \rotatebox{} for this. This webpage describes what \rotatebox{} does:

  1. Rotate the element about the start-of-baseline (graphics) or specified point (grahpicx).
  2. Translate the element horizontally so that the left edge of the new bounding box coincides with the left edge of the bounding box before rotation.

It is the second step that is causing trouble, as I only want to rotate the element, not translate it horizontally afterwards. Consider the following example:

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}
\setlength{\unitlength}{1cm}
\begin{picture}(3,3)
\put(1,1){{\color{red}\circle*{0.1}}}
\put(1,1){\parbox[t]{2cm}{\raggedright{text that is wrapped}}}
\put(2,2){{\color{blue}\circle*{0.1}}}
\put(2,2){\rotatebox[origin=lB]{60}{\parbox[t]{2cm}{text that is wrapped and rotated}}}
\end{picture}
\end{document}

It can be seen that the blue dot is no longer aligned with the start-of-baseline position of the rotated text. This is due to the translation in step #2 (which results in the element being shifted to the right). How can I rotate the element so that the start-of-baseline (or the specified point of rotation more generally) does not move?

EDIT: I would like to be able to specify the point of rotation to be any point, not just the start-of-baseline position. The graphicx version of \rotatebox{} allows this:

\rotatebox[x=TeX dimension,y=TeX dimension]{...}

Best Answer

In response to the edit, here is another option that might work. It is

\rotbox[pole1,pole2]<x-offset,y-offset>{angle}{content}

Where the content is rotated and placed at the specified offset from the point of intersection of pole1 and pole2. See p.2 of the xcoffins documentation for a list of predefined poles (and coffins in general, I've just made a wrapper for pre-existing functionality). Both poles and offsets are optional and have defaults (which you can change) left edge and baseline of typeset material for the poles, and zeros for the offsets. This is my first crack at coffins so I've likely muddled something somewhere.

\documentclass{article}
\usepackage{xcolor}

\ExplSyntaxOn

\cs_generate_variant:Nn \coffin_typeset:Nnnnn {Nffff}

\NewDocumentCommand\rotbox{ O{l,H} D<>{0pt,0pt} m m}{
    % O{l,H}=optional argument[] with default value l,H
    % l=left edge of box, and H=text baseline
    % D<>{0pt,0pt}= optional argument<> with default value 0pt,0pt
    % which are x and y offsets respectively
    % by default the coffin is placed at the intersection of its left
    % edge and the text baseline with no offset from this point.
    \hcoffin_set:Nn \l_tmpa_coffin {#4}
    % put the stuff in a coffin
    \coffin_rotate:Nn \l_tmpa_coffin {#3}
    % rotate it
    \coffin_typeset:Nffff \l_tmpa_coffin 
    % this macro requires 5 args where
    % #1=coffin name, \l_tmpa_coffin above
    % #2=a pole, default left edge
    % #3=another pole, default text baseline
    % #4=x-offset from pole intersection, default 0pt
    % #5=y-offset from pole intersection, default 0pt
        {\clist_item:nn{#1}{1}}
        % #1 of \rotbox is a comma separated list with default l,H
        % take the first item from this clist, this is our first pole
        {\clist_item:nn{#1}{2}}
        % #1 of \rotbox is a comma separated list with default l,H
        % take the second item from this clist, this is our next pole
        {\clist_item:nn{#2}{1}}
        % #2 of \rotbox is a comma separted list with default 0pt,0pt
        % get x-offset as first item on this list
        {\clist_item:nn{#2}{2}}
        % #2 of \rotbox is a comma separted list with default 0pt,0pt
        % get y-offset as second item on this list
}
\ExplSyntaxOff

\begin{document}

\setlength{\unitlength}{1cm}
\begin{picture}(3,3)
\put(2,2){{\color{blue}\circle*{0.1}}}
\put(2,2){\rotbox{60}{\parbox[t]{2cm}{text that is wrapped and rotated}}}
\end{picture}

\begin{picture}(3,3)
\put(2,2){{\color{blue}\circle*{0.1}}}
\put(2,2){\rotbox[hc,vc]{60}{\parbox[t]{2cm}{text that is wrapped and rotated}}}
\end{picture}
\end{document}

enter image description here


(Old answer) I think that this might be what you're after:

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{rotating}

\begin{document}
\setlength{\unitlength}{1cm}
\begin{picture}(3,3)
\put(1,1){{\color{red}\circle*{0.1}}}
\put(1,1){\parbox[t]{2cm}{\raggedright{text that is wrapped}}}
\put(2,2){{\color{blue}\circle*{0.1}}}
\put(2,2){\turnbox{60}{\parbox[t]{2cm}{text that is wrapped and rotated}}}
\end{picture}
\end{document}

enter image description here

Related Question