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 use minipages to place three graphs, however the spaces between each two is not with the same width. Here is the code, may someone help me? and how to locate the (a) (b) (c) above the each of the graph?

    \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
    shapes.geometric,
    positioning,
    fit,
    calc
}
\usepackage{scalefnt}
\begin{document}
\begin{figure}[htbp]
\hspace{-4mm}
\begin{minipage}{0.33\linewidth}
\centering
%\includegraphics[width=2.3in]{image/CompositionalStucture}
(a)
\tikzset{
 block/.style = {circle, draw,align=center,inner sep=0pt},
 line/.style = {draw,->},
 }
{\scalefont{0.8}
\begin{tikzpicture}[node distance=15mm]
\node[block,minimum size=6mm] (s2) {1};
\node[block,right of =s2,anchor=center,minimum size=4mm] (s3){2};
\node[block, right of=s2,anchor=center,,minimum size=6mm] (s4) {};

\path[line] (-0.8,0)-- (s2){};
\path[line] (s2)-- node[above]{Err}(s4);
\path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$/Err}(s2);
\path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
\end{tikzpicture}
}
%\red{2}
\end{minipage}
\begin{minipage}{0.33\linewidth}
\centering
%\includegraphics[width=2.3in]{image/CompositionalStucture}
(b)
\tikzset{
 block/.style = {circle, draw,align=center,inner sep=0pt},
 line/.style = {draw,->},
 }
{\scalefont{0.8}
\begin{tikzpicture}[node distance=15mm]
\node[block,minimum size=6mm](s2) {1};
\node[block,right of =s2,anchor=center,minimum size=4mm] (s3){2};
\node[block, right of=s2,anchor=center,minimum size=6mm] (s4) {};

\path[line] (-0.8,0)-- (s2){};
\path[line] (s2)-- node[above]{ru}(s4);
\path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$/ru}(s2);
\path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
\end{tikzpicture}
}
%\red{3}
\end{minipage}
\begin{minipage}{0.33\linewidth}
\centering
%\includegraphics[width=2.3in]{image/CompositionalStucture}
(c)
\tikzset{
 block/.style = {ellipse, draw,align=center,inner sep=0pt},
 line/.style = {draw,->},
 }
{\scalefont{0.8}
\begin{tikzpicture}[node distance=10mm]
\node[align=center](s1) {\ldots};
\node[block,minimum size=3.5mm,below of =s1](s5) {(19,1)};
\node[block,minimum size=3.5mm,below of = s5](s6) {(20,2)};

\path[line] (s1)-- (s5);
\path[line] (s5)-- node[right]{ru}(s6);
\end{tikzpicture}
}
%\red{3}
\end{minipage}
\caption{Monitoring Automata}
\label{fig:monitoringAutomata}
\end{figure}

\end{document} 

enter image description here

share|improve this question
    
Please, try to use the proper tags for your questions: not always you have to use the combination tikz-pgf,tikz-styles,tikz-trees. –  Claudio Fiandrino Feb 26 '13 at 10:02
    
@ClaudioFiandrino sorry. Thanks for editing and reminder, I will take it care next time –  sweetyBaby Feb 26 '13 at 10:32
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs May 4 '13 at 13:43
add comment

1 Answer

The reason of the different spaces are linked to the use of minipage: you define blocks of fixed width and your picture inside these blocks does not fill the whole blocks, leaving different empty spaces. You can see them if you put your minipages in an \fbox{...} block.

enter image description here

You may better take a look at the subcaption package, or position manually the spaces using \hspace{dimension} like that:

\begin{tikzpicture}
% picture A
\end{tikzpicture}
\hspace{5mm}
\begin{tikzpicture}
% picture B
\end{tikzpicture}

Edit: usage of subcaption package

\documentclass[a4paper]{article}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{
    shapes.geometric,
    positioning,
    fit,
    calc
}
\usepackage{scalefnt}
\begin{document}
\begin{figure}[htbp]
    \centering
    \subcaptionbox{}{
        \tikzset{
             block/.style = {circle, draw,align=center,inner sep=0pt},
             line/.style = {draw,->},
         }
        \scalefont{0.8}
        \begin{tikzpicture}[node distance=15mm]
            \node[block,minimum size=6mm] (s2) {1};
            \node[block,right of =s2,anchor=center,minimum size=4mm] (s3){2};
            \node[block, right of=s2,anchor=center,,minimum size=6mm] (s4) {};

            \path[line] (-0.8,0)-- (s2){};
            \path[line] (s2)-- node[above]{Err}(s4);
            \path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$/Err}(s2);
            \path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
        \end{tikzpicture}
    }
    \subcaptionbox{}{
        \tikzset{
             block/.style = {circle, draw,align=center,inner sep=0pt},
             line/.style = {draw,->},
         }
        \scalefont{0.8}
        \begin{tikzpicture}[node distance=15mm]
            \node[block,minimum size=6mm](s2) {1};
            \node[block,right of =s2,anchor=center,minimum size=4mm] (s3){2};
            \node[block, right of=s2,anchor=center,minimum size=6mm] (s4) {};

            \path[line] (-0.8,0)-- (s2){};
            \path[line] (s2)-- node[above]{ru}(s4);
            \path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$/ru}(s2);
            \path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
        \end{tikzpicture}
    }
    \subcaptionbox{}{
        \tikzset{
             block/.style = {ellipse, draw,align=center,inner sep=0pt},
             line/.style = {draw,->},
         }
        \scalefont{0.8}
        \begin{tikzpicture}[node distance=10mm]
            \node[align=center](s1) {\ldots};
            \node[block,minimum size=3.5mm,below of =s1](s5) {(19,1)};
            \node[block,minimum size=3.5mm,below of = s5](s6) {(20,2)};

            \path[line] (s1)-- (s5);
            \path[line] (s5)-- node[right]{ru}(s6);
        \end{tikzpicture}
    }
    \caption{Monitoring Automata}
    \label{fig:monitoringAutomata}
\end{figure}

\end{document}

enter image description here

** Edit 2:** To put all the picture in the same row, you could use \resizebox{width}{height}{box}. On the below example, I have rescaled the middle picture to demonstrate the use of the command.

\documentclass[a4paper]{article}
\usepackage{subcaption}
\usepackage{tikz}
\usepackage{lipsum}
\usetikzlibrary{
    shapes.geometric,
    positioning,
    fit,
    calc
}
\usepackage{scalefnt}

\begin{document}
\lipsum[1]

\begin{figure}[h!]
    \centering
    \resizebox{\linewidth}{!}{%
    \subcaptionbox{}{%
        \tikzset{
             block/.style = {circle, draw,align=center,inner sep=0pt},
             line/.style = {draw,->},
        }
        \scalefont{0.8}
        \begin{tikzpicture}[node distance=15mm]
            \node[block,minimum size=6mm] (s2) {1};
            \node[block,right of =s2,anchor=center,minimum size=4mm] (s3){2};
            \node[block, right of=s2,anchor=center,,minimum size=6mm] (s4) {};

            \path[line] (-0.8,0)-- (s2){};
            \path[line] (s2)-- node[above]{Err}(s4);
            \path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$/Err}(s2);
            \path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
        \end{tikzpicture}
    }
    \subcaptionbox{}{\scalebox{4}{% For demonstration purpose!
        \tikzset{
             block/.style = {circle, draw,align=center,inner sep=0pt},
             line/.style = {draw,->},
        }
        \scalefont{0.8}
        \begin{tikzpicture}[node distance=15mm]
            \node[block,minimum size=6mm](s2) {1};
            \node[block,right of =s2,anchor=center,minimum size=4mm] (s3){2};
            \node[block, right of=s2,anchor=center,minimum size=6mm] (s4) {};

            \path[line] (-0.8,0)-- (s2){};
            \path[line] (s2)-- node[above]{ru}(s4);
            \path[line] (s2) to [out=120,in=40,looseness=5] node[above] {$\Sigma$/ru}(s2);
            \path[line] (s4) to [out=120,in=40,looseness=5]node[above] {$\Sigma$}(s4);
        \end{tikzpicture}
    }}
    \subcaptionbox{}{%
        \tikzset{
             block/.style = {ellipse, draw,align=center,inner sep=0pt},
             line/.style = {draw,->},
         }
        \scalefont{0.8}
        \begin{tikzpicture}[node distance=10mm]
            \node[align=center](s1) {\ldots};
            \node[block,minimum size=3.5mm,below of =s1](s5) {(19,1)};
            \node[block,minimum size=3.5mm,below of = s5](s6) {(20,2)};

            \path[line] (s1)-- (s5);
            \path[line] (s5)-- node[right]{ru}(s6);
        \end{tikzpicture}
    }
    } % resizebox
    \caption{Monitoring Automata}
    \label{fig:monitoringAutomata}
\end{figure}
\lipsum[2]

\end{document} 

Note: ! as height means "calculate the height to keep the aspect ratio"

enter image description here

share|improve this answer
    
thanks, however, when I use the subcaption package, only two display at the same line, the third graph is below of the first two, may I know how to reduce the space so that three graphs can display at the same line? –  sweetyBaby Feb 26 '13 at 10:49
    
use \resizebox{width}{height}{box}, see my 2nd edit –  Lionel MANSUY Feb 26 '13 at 12:38
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.