我想picture
围绕指定点旋转环境中的元素。我尝试过\rotatebox{}
这样做。此网页描述了什么\rotatebox{}
:
- 围绕基线起点 (
graphics
) 或指定点 (grahpicx
) 旋转元素。 - 水平平移元素,使得新边界框的左边缘与旋转之前的边界框的左边缘重合。
第二步造成了麻烦,因为我只想旋转元素,而不是随后水平平移它。请考虑以下示例:
\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}
可以看出,蓝点不再与旋转文本的基线起始位置对齐。这是由于步骤 #2 中的平移(导致元素向右移动)。如何旋转元素以使基线起始(或更一般地指指定的旋转点)不移动?
编辑:我希望能够将旋转点指定为任意点,而不仅仅是基线起点位置。graphicx
的版本\rotatebox{}
允许这样做:
\rotatebox[x=TeX dimension,y=TeX dimension]{...}
答案1
作为对编辑的回应,这里是另一个可能有效的选项。它是
\rotbox[pole1,pole2]<x-offset,y-offset>{angle}{content}
pole1
内容被旋转并放置在与交点的指定偏移处pole2
。请参阅xcoffins 文档第 2 页提供了预定义极点的列表(对于棺材,我刚刚为预先存在的功能做了一个包装)。极点和偏移都是可选的,并且具有默认值(您可以更改),即极点的排版材料的左边缘和基线,以及偏移的零。这是我第一次尝试制作棺材,所以我可能在某个地方弄混了。
\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}
(旧答案)我认为这可能是你想要的:
\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}