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 a problem with the subfigenvironment. My two graphs created with pgfplots are too large to stay together. How can I fix that?

% Graphique
\begin{figure}
\centering
\subfloat[]{$\tau = \SI{0.1}{\second}$}
    {\begin{tikzpicture}
    \begin{axis}[title={Trajectoire de la balle dans le plan $x$-$z$}, xlabel={$x$}, ylabel={$z$},%
    legend cell align=left]

        \addplot[red,thick,each nth point={10}]
            table[x index=1,y index=3] {Data/magnus_nog_not_dt0.1s.dat};

        \legend{}
    \end{axis}
    \end{tikzpicture}} \quad

\subfloat[]{$\tau = \SI{0.001}{\second}$}
    {\begin{tikzpicture}
    \begin{axis}[title={Trajectoire de la balle dans le plan $x$-$z$}, xlabel={$x$}, ylabel={$z$},%
    legend cell align=left]

        \addplot[red,thick,each nth point={10}]
            table[x index=1,y index=3] {Data/magnus_nog_not_dt0.001s.dat};

        \legend{}
    \end{axis}
    \end{tikzpicture}}

    \caption[]{}\label{g:nognot}
\end{figure}
% Graphique

Ps: I didn't provide a MWE because you need files to compile my graphs.

share|improve this question
    
If they don't fit, they don't so maybe make them smaller with width=0.4\textwidth ? –  percusse Oct 6 '12 at 20:31
    
@percusse The graphs are small, so I don't want to make them even smaller. In addition, I want all my graphs look the same way... ;) –  R. M. Oct 6 '12 at 20:40
    
Yes but what do you expect from us then? The question is not answerable because there is not much else to do. –  percusse Oct 6 '12 at 20:53
    
@percusse Maybe there is some configuration of subfig that permit to the environment to exceed \textwidth... No? There is anything to do? –  R. M. Oct 6 '12 at 21:00
    
@R.M. So you want the graphs side by side, no matter if they exceed the margins? If that's so, then perhaps my answer could be useful. –  Gonzalo Medina Oct 6 '12 at 21:14
add comment

1 Answer 1

up vote 3 down vote accepted

From the comments it seems that was is required is a method to have the two graphs in the same row, no matter if the margins are exceeded; one way to achieve this is using a \makebox:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning}
\usepackage{subfig}
\usepackage{lipsum}

\begin{document}

\lipsum[2]
\begin{figure}
\centering
\makebox[\textwidth][c]{%
\subfloat[]{%
  \begin{tikzpicture}
  \draw (0,0) grid (7,3);
  \end{tikzpicture}}\quad
\subfloat[]{%
  \begin{tikzpicture}
  \draw (8,0) grid (15,3);
  \end{tikzpicture}}
}\\
\makebox[\textwidth][c]{%
\subfloat[]{%
  \begin{tikzpicture}
  \draw (0,0) grid (7,3);
  \end{tikzpicture}}\quad
\subfloat[]{%
  \begin{tikzpicture}
  \draw (8,0) grid (15,3);
  \end{tikzpicture}}
}
\caption[]{}
\label{g:nognot}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
That's what I need, thank you. The problem now is that it seems the \\ command is ignored: the 4 graphs are placed in a single line instead of two lines... How I can fix that? –  R. M. Oct 6 '12 at 21:23
    
@R.M. Sorry but how can we anticipate four graphs in two rows when you only mentioned two graphs in your question? Anyway, the idea is the same: you can use two \makeboxes (one for each row); I'll update my answer with an example. –  Gonzalo Medina Oct 6 '12 at 21:35
    
@R.M. I've updated my answer. –  Gonzalo Medina Oct 6 '12 at 21:37
    
Sorry! I posted an old version of my code! –  R. M. Oct 6 '12 at 21:38
    
@R.M. No problem; just make sure to provide precise information in your questions ;-) Did my updated answer helped? –  Gonzalo Medina Oct 6 '12 at 21:40
show 2 more comments

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.