6

I have a standalone document of the form:

\documentclass[tikz]{standalone}
%\documentclass{article}
%\usepackage{tikz}

\usetikzlibrary{positioning}

\newcommand{\tikzmark}[2]{\tikz[remember picture, baseline] \node[inner sep=0pt, outer sep=0pt, anchor=base] (#1) {#2};}

\begin{document}

\begin{tikzpicture}[remember picture]
\node (A) {
\begin{tabular}{ll}
1 & \tikzmark{two}{2} \\
3 & 4 \\
\end{tabular}};

\node[right=of A] (B) {
\begin{tabular}{ll}
5 & 6 \\
\tikzmark{seven}{7} & 8 \\
\end{tabular}};
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay]
\draw[->] (two) -- (seven);
\end{tikzpicture}
\end{document}

The contents are displayed correctly when using the article documentclass instead of standalone.

Can anyone suggest how to make it so that the contents of all tikzpictures are displayed?

11
  • 1
    The way you are doing it causes pdflatex to put every tikzpicture on a separate page of the document. Do you want all your tikzpictures on one page?
    – moospit
    Commented Aug 22, 2014 at 8:36
  • All of the tikzpictures fit on a single page. Some of the contents of the second and third ones are overlaid on the first. I have tried \documentclass[tikz=true]{standalone}, but this isn't displaying the contents correctly, either.
    – justinpc
    Commented Aug 22, 2014 at 8:45
  • Don't use different tikzpictures. Put all drawing inside a single tikzpicture environment. standalone produces one page per tikzpicture environment you are using (by design).
    – user11232
    Commented Aug 22, 2014 at 8:50
  • I presume from you comment that you use \documentclass{standalone} \usepackage{tikz} and not \documentclass[tikz]{standalone} as this separates the tikzpictures on single pages. As @HarishKumar says, don't use different tikzpictures, try to use scopes in one tikzpicture instead.
    – moospit
    Commented Aug 22, 2014 at 8:54
  • The reason I need multiple tikzictures is that inside the first tikzpicture, there are tabular environments, some of the elements of which are inline \tikzs. These elements cannot be referred to in the containing tikzpicture. They are referred to in the following tikzpictures. On the preamble: The last thing I tried was \documentclass[multi=tikzpicture, ignorerest=true]{standalone} \usepackage{tikz}, again to no avail.
    – justinpc
    Commented Aug 22, 2014 at 9:00

1 Answer 1

3

Works fine with just one tikzpicture here. You have to compile twice of course.

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}

\newcommand{\tikzmark}[2]{\tikz[remember picture, baseline] \node[inner sep=0pt, outer sep=0pt, anchor=base] (#1) {#2};}

\begin{document}

\begin{tikzpicture}[remember picture]
\node (A) {
\begin{tabular}{ll}
1 & \tikzmark{two}{2} \\
3 & 4 \\
\end{tabular}};

\node[right=of A] (B) {
\begin{tabular}{ll}
5 & 6 \\
\tikzmark{seven}{7} & 8 \\
\end{tabular}};

\draw[->] (two) -- (seven);
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks a lot. This works on my end as well. It turns out that the "overlay" option that I'd given to the single tikzpicture environment was what was creating the problem. I applied this to my original code, and that works fine as well.
    – justinpc
    Commented Aug 22, 2014 at 15:42

You must log in to answer this question.

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