2

I would like to place four tikzpictures on the same horizontal line but I am not able to set the tikzpictures on the same horizontal line (see the LaTeX code below). Using the code reported below, each tikzpicture is placed below the previous tikzpicture (and this is not what I am searching for).

Is there a way to fix this problem?

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{adjustbox}



\begin{document}



    %   1


\begin{adjustbox}{valign=t,minipage={.10\textwidth}}


  \begin{center}
\begin{tikzpicture}[-,thick,    
auto]
    \node (z){0}
child {
    node {a}            };
    \end{tikzpicture}
  \end{center}  

     \end{adjustbox}            


\hfill




                %   2

\begin{adjustbox}{valign=t,minipage={.45\textwidth}}





  \begin{center}
\begin{tikzpicture}[-,thick,    
auto]
    \node (z){0}
child {
    node {b}            };
    \end{tikzpicture}
 \end{center}



     \end{adjustbox}            



    \begin{adjustbox}{valign=t,minipage={.65\textwidth}}





  \begin{center}
  \begin{tikzpicture}[-,thick,  
auto]
    \node (z){0}
child {
    node {b}            };
    \end{tikzpicture}
 \end{center}



     \end{adjustbox}    



\begin{adjustbox}{valign=t,minipage={.85\textwidth}}





  \begin{center}
\begin{tikzpicture}[-,thick,    
auto]
    \node (z){0}
child {
    node {b}            };
    \end{tikzpicture}
  \end{center}



     \end{adjustbox}    






\end{document}
1
  • I suggest you remove the center environment, as it starts a new paragraph. You'd rather use \centering Sep 18, 2015 at 19:33

1 Answer 1

2

The total width of the four minipages is longer than \textwidth; besides, there are blank lines in your code (I don't know wether they are in the actual code or were just result of copy-paste in the question) that shouldn't be there (a blank line ends the paragraph and following material will begin a new paragraph). Adjust the width of the minipages, for example, to 0.25\textwidth and beware of blank spaces (I also changed the center environment to \centering):

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{adjustbox}

\begin{document}

\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
  child {  node {a} };
\end{tikzpicture}
\end{adjustbox}%
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
  child {  node {b} };
\end{tikzpicture}
\end{adjustbox}%            
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
  child {  node {b} };
\end{tikzpicture}
\end{adjustbox}%    
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
  child {  node {b} };
\end{tikzpicture}
\end{adjustbox}    

\end{document}

The result:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .