Vous êtes sur la page 1sur 2

tikz pgf - How do I control the spacing between two tikzpictures?

- TeX - LaTeX Stack Exchange 03/01/18 16(08

_
TeX - LaTeX Stack Exchange is a Here's how it works:
question and answer site for users
of TeX, LaTeX, ConTeXt, and related
typesetting systems. Join them; it
only takes a minute:
The best answers are
Sign up Anybody can Anybody can voted up and rise to the
ask a question answer top

How do I control the spacing between two tikzpictures?

If I have two tikzpictures next to each other, how do I control the spacing
between them?

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[scale=1.5,>=latex, font=\sffamily]
\draw[red] (-1.19,-1.19) rectangle (1.19,1.19);
\draw [->](-1,0) -- (1,0);
\node[right] at (0:0.95) {$\alpha$};
\draw [->](0,-1) -- (0,1);
\node[right] at (90:0.95) {$\beta$};
\end{tikzpicture}
\begin{tikzpicture}[scale=1.5,>=latex, font=\sffamily]
\draw[red] (-1.19,-1.19) rectangle (1.19,1.19);
\def\thetae{345}
\draw [->](-\thetae+180:1) -- (-\thetae:1);
\node[rotate=-\thetae, right] at (-\thetae:0.95) {$\alpha$};
\draw [->](-\thetae+270:1) -- (-\thetae+90:1);
\node[rotate=-\thetae, right] at (-\thetae+90:0.95) {$\beta$};
\end{tikzpicture}

\end{document}

{tikz-pgf} {spacing}

asked May 12 '16 at 15:25


Jason S
978 4 17

1 Answer

Like most latex constructs, a tikzpicture is a box so spacing is controlled as it would

https://tex.stackexchange.com/questions/309284/how-do-i-control-the-spacing-between-two-tikzpictures Página 1 de 2
tikz pgf - How do I control the spacing between two tikzpictures? - TeX - LaTeX Stack Exchange 03/01/18 16(08

be between two letters. You have

\end{tikzpicture}
\begin{tikzpicture}

which is like

hello
world

and puts one word space between them so they are side by side if they fit on the line.

You could have a blank line to put them in separate paragraphs one above the other,
or

\end{tikzpicture}\hfill
\begin{tikzpicture}

to force them out as far as possible, or any other space construct that you need.

Particularly in standalone you might want a fixed width so

\end{tikzpicture}\hspace{1cm}%
\begin{tikzpicture}

edited May 12 '16 at 15:31 answered May 12 '16 at 15:29


David Carlisle
427k 33 1022
1720

what if I want them to be flush against each other? – Jason S May 12 '16 at 15:29

1 @JasonS just put them next to each other, latex doesn't insert any space zzzz zzz stuff to force a
linebreak in this comment: \end{tikzpicture}\begin{tikzpicture} – David Carlisle May 12 '16 at 15:30

3 @JasonS Put a % after \end{tikzpicture} to hide the newline character from TeX. – Henri Menke May
12 '16 at 15:31

If I do \end{tikzpicture}\begin{tikzpicture} there is still a small space between the rectangles,


though – Jason S May 12 '16 at 15:33

1 @JasonS If I use outer sep=0pt,inner sep=0pt on the tikzpicture they touch (but it messes up the inner
node spacing, not sure how to set it just for the outer box) – David Carlisle May 12 '16 at 15:43

https://tex.stackexchange.com/questions/309284/how-do-i-control-the-spacing-between-two-tikzpictures Página 2 de 2

Vous aimerez peut-être aussi