Two tikzpictures side by side
Why the minipages?
\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.33] %[x={10.0pt},y={10.0pt}]
\draw[line width=2pt] (0,0) -- (0,10);
\draw[line width=2pt] (0,0) -- (10,0);
\draw[line width=2pt] (0,10) -- (10,10);
\draw[line width=2pt] (0,10) -- (10,10);
\draw[line width=2pt] (10,0) -- (10,10);
\draw[line width=2pt] (0,0) -- (3,5);
\draw[line width=2pt] (10,0) -- (13,5);
\draw[line width=2pt] (0,10) -- (3,15);
\draw[line width=2pt] (10,10) -- (13,15);
\draw[line width=2pt] (3,5) -- (13,5);
\draw[line width=2pt] (3,5) -- (3,15);
\draw[line width=2pt] (13,5) -- (13,15);
\draw[line width=2pt] (3,15) -- (13,15);
\draw[line width=1pt] (5,0) -- (5,10);
\draw[line width=1pt] (5,10) -- (8,15);
\draw[line width=1pt] (5,0) -- (8,5);
\draw[line width=1pt] (8,5) -- (8,15);
\draw[black, fill=blue,fill opacity=0.5] (5,0) -- (5,10) -- (8,15) -- (8,5) -- cycle;
\end{tikzpicture}% pic 1
\qquad % <----------------- SPACE BETWEEN PICTURES
\begin{tikzpicture}[scale=0.33] %[x={10.0pt},y={10.0pt}]
\draw[line width=2pt] (0,0) -- (0,10);
\draw[line width=2pt] (0,0) -- (10,0);
\draw[line width=2pt] (0,10) -- (10,10);
\draw[line width=2pt] (0,10) -- (10,10);
\draw[line width=2pt] (10,0) -- (10,10);
\draw[line width=2pt] (0,0) -- (3,5);
\draw[line width=2pt] (10,0) -- (13,5);
\draw[line width=2pt] (0,10) -- (3,15);
\draw[line width=2pt] (10,10) -- (13,15);
\draw[line width=2pt] (3,5) -- (13,5);
\draw[line width=2pt] (3,5) -- (3,15);
\draw[line width=2pt] (13,5) -- (13,15);
\draw[line width=2pt] (3,15) -- (13,15);
\draw[line width=1pt] (0,10) -- (10,0);
\draw[line width=1pt] (0,10) -- (3,5);
\draw[line width=1pt] (3,5) -- (10,0);
\draw[black, fill=blue,fill opacity=0.5] (0,10) -- (10,0) -- (3,5) -- cycle;
\draw[line width=1pt] (3,15) -- (10,10);
\draw[line width=1pt] (3,15) -- (13,5);
\draw[line width=1pt] (10,10) -- (13,5);
\draw[black, fill=blue,fill opacity=0.5] (3,15) -- (10,10) -- (13,5) -- cycle;
\end{tikzpicture}% pic 2
\end{center}
\end{document}
Instead of \qquad
you can have \hspace{<length>}
(just remember the form
\end{tikzpicture}% NO SPACE!
\hspace{3cm}% NO SPACE!
\begin{tikzpicture}[...]
so you precisely control the horizontal space between the images. Vertical alignment can be obtained with TikZ methods (look for baseline
in the manual).
Note also that the a4
option is invalid, it should be a4paper
.
Delete the empty line between the minipages. It is like the \par
command. Use instead:
[...]
\end{minipage}
% no empty line here
\begin{minipage}{.2\textwidth}
[...]
Here is another version:
\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\tikzset{mynode/.style={inner sep=2pt,fill,outer sep=0,circle}}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=3,line width=1pt]
\coordinate (1) at (0,0,0);
\coordinate (2) at (0,1,0);
\coordinate (3) at (1,1,0);
\coordinate (4) at (1,0,0);
\coordinate (5) at (0,0,1);
\coordinate (6) at (0,1,1);
\coordinate (7) at (1,1,1);
\coordinate (8) at (1,0,1);
\foreach \x in {1,2,...,8}{
\node[mynode] at (\x) {};
}
\draw (1) -- (2) -- (3) -- (4) -- cycle;
\draw (5) -- (6) -- (7) -- (8) -- cycle;
\draw (1) -- (5) (2) -- (6) (3) -- (7) (4) -- (8);
\draw[thin,fill=blue!50,opacity=0.5] (0.5,0,0) -- (0.5,0,1) -- (0.5,1,1) -- (0.5,1,0) --cycle;
\node at (0.5,-0.2,1) {(\textit{h\,k\,l})};
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}[scale=3,line width=1pt]
\coordinate (1) at (0,0,0);
\coordinate (2) at (0,1,0);
\coordinate (3) at (1,1,0);
\coordinate (4) at (1,0,0);
\coordinate (5) at (0,0,1);
\coordinate (6) at (0,1,1);
\coordinate (7) at (1,1,1);
\coordinate (8) at (1,0,1);
\foreach \x in {1,2,...,8}{
\node[mynode] at (\x) {};
}
\draw (1) -- (2) -- (3) -- (4) -- cycle;
\draw (5) -- (6) -- (7) -- (8) -- cycle;
\draw (1) -- (5) (2) -- (6) (3) -- (7) (4) -- (8);
\draw[thin,fill=blue!50,opacity=0.5] (1) -- (8) -- (6) --cycle;
\draw[thin,fill=blue!50,opacity=0.5] (2) -- (4) -- (7) --cycle;
\node at (0.5,-0.2,1) {(\textit{h\,k\,l})};
\end{tikzpicture}
\end{center}
\end{document}
You can reduce the \coordinate
definition bit by
\foreach \x/\y/\z/\a in {0/0/0/1,0/1/0/2,1/1/0/3,1/0/0/4,0/0/1/5,0/1/1/6,1/1/1/7,1/0/1/8} {
\coordinate (\a) at (\x,\y,\z);
}
if you want.