The graphicx package gives you commands that put content into a *box* and then rotate, scale, or mirror it. The content need not be an image: a sentence, a formula, or a whole tabular — anything that fits in a box can be transformed. This page covers four commands — \rotatebox (rotate), \scalebox (scale by a factor), \reflectbox (mirror horizontally), and \resizebox (scale to a target size) — and the distinction at their heart: do you specify a *factor* or a *target size*?
The graphicx box transforms
To use these commands, load \usepackage{graphicx} in the preamble. Despite the name, they are not just for images. The transforms graphicx defines — \rotatebox, \scalebox, \resizebox (and the starred \resizebox*), and \reflectbox — all work the same way: they set their argument into a box and then transform that whole box. So you can transform not only an image (\includegraphics) but any material that fits in a box — a run of text, a formula, a tabular, and so on.
The organizing idea is the difference between commands that take a factor and commands that take a target size. \scalebox takes a relative factor — “0.8 times the original,” “twice as big.” \resizebox, by contrast, takes an absolute finished size — “5cm wide,” “the full text width” — and works out the factor needed to reach it. \rotatebox takes an angle, and \reflectbox mirrors. The table below gives the overview.
| Command | You give it | Effect |
|---|---|---|
\rotatebox | An angle (degrees) | Rotates the content counter-clockwise |
\scalebox | A factor (relative) | Scales the content up or down by a factor |
\reflectbox | (nothing) | Mirrors the content horizontally |
\resizebox | A target width & height (absolute) | Scales the content to fit that size |
Rotating — \rotatebox
\rotatebox{angle}{content} puts the content in a box and rotates it counter-clockwise by the given angle, in degrees. A positive angle turns it left; a negative angle turns it right. For instance \rotatebox{90}{...} stands the content upright (as if set vertically), while \rotatebox{-90}{...} tips it the other way.
これは \rotatebox{45}{斜めの文字} です。
This is \rotatebox{45}{slanted text}.Here only the phrase “slanted text” is lifted 45 degrees about its lower-left corner, while the surrounding text stays horizontal. Note that the rotated box is taller than the original, so the line it sits on grows to accommodate it.
You can change the pivot with the optional argument [origin=...]. Give origin one or two of l (left), r (right), c (center), t (top), b (bottom), and B (baseline). For example \rotatebox[origin=c]{180}{...} turns the content 180 degrees about the center of its box, flipping it upside down. The default pivot is lB (left-baseline). For finer control, x= and y= set an arbitrary pivot point, and units= redefines the unit of the angle itself (units=-360 gives clockwise; units=6.283185 gives radians).
\rotatebox[origin=c]{180}{さかさま}\quad\rotatebox{90}{タテ}Scaling by a factor & mirroring — \scalebox and \reflectbox
\scalebox{factor}{content} scales the content by a factor. \scalebox{2}{...} doubles it; \scalebox{0.5}{...} halves it. The factor applies equally in both directions, so the shape (aspect ratio) is preserved.
To stretch the two directions separately, give a vertical factor as the (optional) second argument. The form is \scalebox{h-factor}[v-factor]{content}. \scalebox{1}[2]{...} leaves the width alone but stretches the height to twice its size; \scalebox{0.8}[1.2]{...} makes it 0.8 wide and 1.2 tall. Omit the vertical factor and it defaults to the horizontal one, giving a uniform scale.
\scalebox{2}{大きく}\quad\scalebox{0.5}{小さく}\quad\scalebox{1}[2]{縦長}A factor may be negative, which reflects along that axis. \scalebox{-1}[1]{...} is horizontal factor −1, vertical factor 1 — a horizontal mirror image (mirror writing). This is common enough that graphicx provides the shorthand \reflectbox{content}: it means exactly \scalebox{-1}[1]{...}. Likewise \scalebox{1}[-1]{...} gives a vertical flip.
Able was I \reflectbox{Able was I}Here the phrase “Able was I” is followed by its mirror image — the same phrase flipped left-to-right.
Scaling to a target size — \resizebox
\resizebox{width}{height}{content} scales the content to a specified finished size. Where \scalebox is relative (“so many times the original”), \resizebox takes an absolute target size — “5cm wide,” “2cm tall” — and LaTeX computes the factor that reaches it. \resizebox{3cm}{2cm}{...} stretches the content (independently in each direction) to be exactly 3cm wide and 2cm tall.
To fix just one dimension while keeping the aspect ratio, put an **exclamation point !** in the other. The ! direction simply reuses the factor derived from the specified one. This is the most common form of the command: \resizebox{\textwidth}{!}{...}, for example, makes the content exactly as wide as the text and scales the height in proportion. \resizebox{!}{1cm}{...} makes it 1cm tall with the width following.
Inside the size arguments you may use \width, \height, \totalheight, and \depth, which stand for the content’s original dimensions. \resizebox{2\width}{!}{...} means “make it twice its original width.” The starred form \resizebox*{width}{height}{content} interprets the second argument as height + depth (the total height, including any descent below the baseline), whereas the unstarred form counts only the height above the baseline.
% 元の幅の倍に
\resizebox{2\width}{!}{倍の幅}
% 高さ 1cm、横は比例
\resizebox{!}{1cm}{Tall}Shrinking an over-wide table
The most common practical use of \resizebox is to shrink a table that overruns the text width so it fits. Wrap the whole tabular in \resizebox{\textwidth}{!}{...} and the entire table is scaled down to exactly the text width. Because the box transforms do not care what is inside, a table works just as well as anything else.
\resizebox{\textwidth}{!}{%
\begin{tabular}{lrrr}
項目 & 第1四半期 & 第2四半期 & 第3四半期 \\
\hline
売上 & 120 & 138 & 151 \\
費用 & 80 & 84 & 90 \\
\end{tabular}%
}But this trick is a double-edged sword. Because \resizebox scales everything inside, the text included, a hard shrink yields type smaller than the body — sometimes hard to read — and out of step with the surrounding text. Re-specifying a font size for the table afterward has no effect, since the whole box is scaled down in the end. So the proper fix is to make the table itself fit the width first — adjust column widths, use \small and friends, or drop columns — and treat \resizebox as a last resort. See the table-layout page for details.
adjustbox: a higher-level alternative
The graphicx commands are spare and powerful, but combining them tends to nest deeply. The adjustbox package (load with \usepackage{adjustbox}) is a higher-level alternative that folds them into a single \includegraphics-style key-value interface. With \adjustbox{key=value,...}{content} you can set angle= (rotate), scale= (factor), width=/height= (target size), reflect (mirror), and more at once; a matching adjustbox environment is provided too.
\adjustbox{angle=45,scale=0.8}{まとめて変形}
\adjustbox{max width=\textwidth}{%
\begin{tabular}{lrr} ... \end{tabular}%
}Especially handy is max width=\textwidth (and max totalheight=, etc.). The previous section’s \resizebox{\textwidth}{!}{...} will also enlarge a table that is narrower than the text, whereas max width= only shrinks when the content overflows and leaves it untouched otherwise. So tables that fit keep the body’s type, and only the over-wide ones are scaled down. For documents that lean on rotation, scaling, and mirroring — or when you want overflow handled cleanly — adjustbox is the more comfortable choice.