Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

migrated from stackoverflow.com Jan 20 '11 at 14:57

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

3 Answers

up vote 3 down vote accepted

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{adjustbox}
\usepackage{subfig}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\subfloat{Test figure}
\subfloat[The ball]{%
  \trimbox{-1cm 0cm -1cm 0cm}{%
    \begin{tikzpicture}
      \node[circle,shading=ball,ball color=red!80!white,minimum size=2cm] {};
    \end{tikzpicture}}}
\subfloat{Test figure}
\end{figure}
\end{document}

Without \trimbox:

subfigures

With \trimbox:

widened subfigure

share|improve this answer
add comment

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

share|improve this answer
1  
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
3  
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
add comment

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}
      \node[circle,shading=ball,ball color=red!80!white,minimum size=2cm] {};
    \end{tikzpicture}
    \caption{The ball}
\end{subfigure}
\begin{subfigure}{0.09\textwidth}
\centering
\rule{30pt}{20pt}
\caption{}
\end{subfigure}
\end{figure}
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.