Rotating Text, Tabulars and Images Herbert Voft* March 3, 2007 Abstract To rotate objects like words, tables or images seems to be very easy with I^Tj^X but it is sometimes difficult together whith a floating environment, which should be rotated together with the caption. It maybe a good idea to read first Keith Reckdahls introduction [ ] or the one from Axel Reichert[ article ... :-) or the the Graphics Companion [ ], before reading this *vossOperce.de 1 CONTENTS 1 INTRODUCTION Contents 1 Introduction 2 2 Landscape Mode 3 2.1 PostScript............................... 4 2.2 PDF.................................. 4 3 graphics.sty 5 3.1 \rotatebox command....................... 5 3.2 \ref lectbox command...................... 6 4 Package rotating 7 4.1 rotate Environment........................ 8 4.2 turn Environment.......................... 8 4.3 sideways Environment....................... 9 4.4 sidewaystable Environment................... 10 4.5 sidewaysf igure Environment.................. 10 5 Rotating inside Floats 13 6 Vertical Text beside a Float 14 References 14 List of Figures 1 Demo of the Referencepoint (red disc)............... 6 2 Demo for different Options of package rotating......... 8 3 A sidewaysf igure environment Example............ 12 4 Put some raggedright Text Beside an Image............ 14 5 Put some Text Beside an Image................... 14 List of Tables 1 A sidewaystable environment Example ............ 11 1 Introduction There is no difference in rotating text, images, tables or any other object. This is the reason why you can use every macro (command or environment) for any object. There are several different packages which are discussed in this paper. Some of them are similiar and some may cause problems with other packages. The code for the image on the titlepage is: 1 \newcoramand\demoText{\huge Herbert \begin{rotate} {45} \huge V o !i\ end{rotate}} 2 \unitlengthlcm 3 \begin{center} 4 \begin{picture}(10,10) 2 2 LANDSCAPE MODE 5 \put(5,5) {* 6 \multido{\n=0+15}{24}{% 7 \begin{rotate}{\n}{\demoText}\end{rotate}% s } * 9 } 10 \end{picture} 11 \end{center} 2 Landscape Mode There are different packages for PostScript and PDF output. The landscape mode is an environment and it starts by default a new page, because it changes the two lengths paperwidth and paperheight. The following subsection 2.1 is included in an environment like: 1 \begin{landscape} 2 \subsection{PostScript}\label{ps} 3 Write in the preamble \verb|\usepackage{lscape}|\index{lscape}. The package is available at CTAN.\footnote{\url{ftp://ftp.dante.de/tex-archive/macros/latex/required/graphics/lscape.dtx}} 4 \end{landscape} The \begin {landscape} immediately starts the new page, a lot of vertical whitespace, like the one on this page, maybe possible. 3 Only the text part is in landscape, the header and footer are still in portrait mode. If you want the whole document to be in landscape, use the class option landscape and pass this to dvips with \usepackage [dvips] {geometry}. With the package \ifpdf1 package you can load the right package: \usepackage{ifpdf} \ifpdf* \usepackage{pdflscape} \else \usepackage{lscape} \fi 2.1 PostScript Write in the preamble \usepackage {lscape}. The package is available at CTAN.2 2.2 PDF Write in the preamble \usepackage {pdf lscape}. The package is available at CTAN.3 Choose only this package, because it loads itself the lscape one to overwrite some code. *f tp: / /f tp. dante. de/tex- archive/macros/latex/contrib/supported/oberdiek/if pdf. sty 2f tp: / /f tp. dante. de/tex - archive/macros/latex/required/graphics/lscape.dtx 3ftp://ftp.dante.de/tex-archive/macros/latex/contrib/supported/oberdiek/pdflscape.sty 3 GRAPHICS. STY 3 graphics, sty 3.1 \rotatebox command This macro is part of the \graphicx package.4 The syntax is: \rotatebox[options]{angle}{\ [■■■} 1 This macro leaves additional space for the rotated object. This is an impor- J? tant fact, X> 1 [...] This is an important fact, 2 \rotatebox{40}{* 3 because we \textbf{cannot} overwrite some other stuff.* 4 } The following options are possible and belong only to the rotation point: origin=|It|ct|rt|lc|c|rc|IB|cB|rB|lb|cb|rb| x=xdim y=ydim The first letter 1 | c | r is an abbreviation for lef 11 center | right and the second one 11 c | B | b for top | center | baseline | bottom. The order is not important and c is the same than cc. Alternative the rotation point can be specified with its coordinates relative to the referenc point IB (left Baseline), which is the default, too. It is not possible to rotate text which includes a verbatim Environment environment or the \verb macro. In this case choose one of the following macros from the rotating Environment package. Figure 1 shows the different rotation modes. The rotating point is marked with a red disc and all boxes are rotated anti clockwise by 30 degrees. As an example here is the code for the option=lb mode: 1 [...] 2 \newcoramand{\Hoehe}{\ht\FrBox\Gobble} 3 \newcoramand{\Breite}{\wd\FrBox\Gobble} 4 \newcoramand{\Tiefe}{\dp\FrBox\Gobble} 5 \newlength{\totalHeight} 6 \setlength{\totalHeight}{\ht\FrBox} 7 \addtolength{\totalHeight}{\dp\FrBox} s \newcoramand{\tHoehe}{\totalHeight\Gobble} 4f tp: I If. tp. dante. de/tex- archive/macros / latex/required/graphics / 5 3.2 \reflectbox command 3 GRAPHICS.STY [■■■] \subf \put( \begi \end{ }\hfi [. . .] igure[option=lb]{% 0,-\Tiefe){\textcolor{red}{\circle*{3}}}* n{picture}(\Breite,\Hoehe) \put(0,-\Tiefe){\textcolor{red}{\circle*{3}}} \put(0,0){\usebox{\FrBox}} \put(-0.5\tHoehe,0) {\rotatebox[origin=lb] {\rotAngle} {\usebox{\ FrBox}}} picture} 11 3.2 \ref lectbox command This command is defined in graphics . sty and mirrors an object at the left vertical border, f.ex.: xocfj09ft9i refiectbox 6 4 PACKAGE ROTATING The syntax is very easy: \reflectbox{} ref lectbox can beused with any kind of objects. It is only a synonym for the \scalebox command: \scalebox{ -1} {1} {} 4=> \reflectbox 4 Package rotating The graphicx package has the makro \rotatebox which still has some problems, f.ex. with text in verbatim mode. It is better to use the rotating package5. This package has the following options: clockwise: (the default) counts the angle anti clockwise (leftturn). This is only for compatibility to [ ], where positive angles are counted clockwise. counterclockwise: same other way round (rightturn) figuresleft: (the default) the figures are placed to the left, which depends to the twoside option if it appears on top or bottom of the page figuresright: the other way round Figure 2 shows the difference between figuresleft and figuresright. These two options only make sense with the sideways figure floating environment and when you want them on the same side in twoside mode. The options have no effect, when center the images/tables with the \centering command. The rotating package provides the commands or environments 5f tp: / /f tp. dante. de/tex- archive/macros/latex/contrib/supported/rotating/ 7 4.1 rotate Environment 4 PACKAGE ROTATING Figure 2: Demo for different Options of package rotating rotate turn sideways sidewaysfigure sidewaystable Only the first two have an additional argument, the value of the rotating angle. 4.1 rotate Environment ^e> The syntax is ^ * \begin{rotate} {angle} [---] \end{rotate} This environment does not leave ggfy additional vertical space for the rotated object. This is an important fact,^2, [...] This is an important fact, \begin{rotate}{40} because we \textbf{can} overwrite some other stuff. \end{rotate} 4.2 turn Environment The syntax is \begin{turn}{} [. . .] \end{turn} 8 4.3 sideways Environment 4 PACKAGE ROTATING This environment leaves in difference to rotate additional vertical space for cr J? the rotated object. This is an important fact, X> This is the same behaviour as for the \rotatebox command (see section 3.1). [...] This is an important fact, \begin{rotate}{40} because we \textbf{cannot} overwrite some other stuff. \end{rotate} 4.3 sideways Environment This environment is a special one for turn. It always rotates with the fixed angle a — 90 and leaves additional vertical space for the rotated object. The syntax is different to the forgoing environments, because we do not need an additional parameter: \begin{sideways} [. . .] \end{s i deways} This environment leaves in difference to rotate additional space for the it a; c a; E c a; = re rotated object. This is an important fact, -c [...] This is an important fact, \begin{sideways} because we \textbf{cannot} overwrite some other stuff. \end{s i deways} 9 4.4 sidewaystable Environment 4 PACKAGE ROTATING 4.4 sidewaystable Environment This environment is for a floating object. The rotation of the object is the same than for sideways. The syntax is \begin{sidewaystable} [ < a tabular > ] \caption{< text >} \end{s i deways tab1e} This environment leaves in difference to rotate additional vertical space for the rotated object. This is an important fact, because it takes a whole page (table 1). This is the same way than using the landscape environment. \begin{sidewaystable} \centering \begin{tabular}{cc|c} a & b & l\\\hline c & d & 2 \end{tabular} \caption[A \texttt{sidewaystable} environment Example]{A Demonstration for the \texttt{sidewaystable} environment. This float has its own page. The only way to get some more text is to put this into the float itself.}\label{tab:sideways} \end{s i deways tab1e} This environment is handled like a floating object, so that I^TgK fills up the page before this sideways table with text which was written after this environment, like this text. Table 1 shows that there is a bad behaviour when the caption has a lot of text. In this case it is a good idea to use a parbox inside the caption like the one from figure 3. For more information about the caption layout have a look at the different caption packages.6 4.5 sideways figure Environment This environment is just the same than the sidewaystable with the only difference, that it is a figure and not a table object. The syntax is \begin{sidewaysfigure} [ < any object > ] \caption{< text >} \end{sidewaysfigure} This environment leaves in different to rotate additional vertical space for the rotated object. This is an important fact, because it takes a whole page (figure 3). This is the same way than using the landscape environment. \begin{sidewaysfigure} \centering \includegraphics{rose} \caption[A \texttt{sidewaysfigure} environment Example]{\parbox[t]{0.5\ linewidth}{A Demonstration for the \texttt{sidewaysfigure} environment, which has the same behaviour than the \texttt{sidewaystable} environment (see \rabox{table \ref{tab:sideways}})}}\label{fig:sideways} \end{sidewaysfigure} 6ftp://ftp.dante.de/tex-archive/macros/latex/contrib/supported/caption/ ftp://ftp.dante.de/tex-archive/macros/latex/contrib/supported/ccaption/ 10 in a b 1 c d 2 to a a> ^ to Hi h-j.