# How do I set the minimum width of a subfigure?

I have:

\subfigure[blah blah blah.]
{
\begin{tikzpicture}[/MyStyle]
... some stuff...
\end{tikzpicture}
}


But "some stuff" is not that wide and the text in the subfigure produces a lot of underfull hboxes. I want to make the subfigure wider. How do I do that?

-

## migrated from stackoverflow.comJan 20 '11 at 14:57

This question came from our site for professional and enthusiast programmers.

Probably this question was asked before tex.stackexchange.com was created but now is available I think this should be moved there. –  nacho4d Jan 19 '11 at 15:08

A general approach for customizing the width and the height of a subfigure is using the adjustbox package. It provides features for trimming (also with negative value, so enlarging), clipping, scaling, rotating etc. which can be applied also to TikZ pictures.

An example where the subfigure has been made wider by 1 cm on the left and on the right:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\subfloat{Test figure}
\subfloat[The ball]{%
\trimbox{-1cm 0cm -1cm 0cm}{%
\begin{tikzpicture}
\end{tikzpicture}}}
\subfloat{Test figure}
\end{figure}
\end{document}


Without \trimbox:

With \trimbox:

-

You could alter the width of the tikz picture. I don't know if subfigure itself has any width attribute. It normally inherits its size from whatever is inside it, as far as I know

-
How do I alter the width of a tikz picture? –  Neil G Jul 21 '10 at 22:36
(I have been inserting blank nodes, but this is ugly.) –  Neil G Jul 21 '10 at 22:36
You can use something like \useasboundingbox (-1,-1) rectangle (4,4); to grow (or shrink) the space a tikz picture takes. The actual picture is not changed. Of course you can also grow/shrink the picture itself with a \begin{tikzpicture}[scale=1.5] –  Ivan Andrus Jul 22 '10 at 7:08
Can tikz pictures not just take a width=... argument? –  Seamus Jul 22 '10 at 11:02
Thanks Seamus and Ivan Andrus! –  Neil G Jul 26 '10 at 2:58

Another option is to use the subfigure environment from the subcaption package.

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{figure}
\begin{subfigure}{0.09\textwidth}
\centering
\rule{30pt}{20pt}
\caption{}
\end{subfigure}
\begin{subfigure}{0.8\textwidth}
\centering
\begin{tikzpicture}