3

I always think standalone will display my drawings at center but below example seems clipped (the red lines).

\documentclass[border=5pt]{standalone}
\usepackage{tikz,booktabs,array}

\begin{document}

\tikzset{>=latex} 
\tikzstyle{every picture}+=[remember picture,baseline]
\tikzstyle{every node}+=[inner sep=0pt,anchor=base,
    minimum width=.5cm,align=center,text depth=.25ex,outer sep=1.5pt]
\tikzstyle{every path}+=[very thick]

\newcommand{\tikzmark}[2]{\tikz \node (#1) {#2};}

\begin{tabular}{|>{\bfseries}c|>{\bfseries}c|}
    \toprule
    \hline
 \tikzmark{m00}{Number} & \tikzmark{m01}{Name} \\ \hline
  \tikzmark{m10}{0} & \tikzmark{m11}{Jack} \\ \hline
  \tikzmark{m20}{1} & \tikzmark{m21}{Mary} \\ \hline
  \tikzmark{m30}{2} & \tikzmark{m31}{John} \\ \hline
  \tikzmark{m40}{3} & \tikzmark{m41}{Alice} \\ \hline
    \bottomrule
\end{tabular}

\begin{tikzpicture}[overlay,remember picture]
\coordinate (P) at ([xshift=20pt]m21.east);
\draw[red] (m11.east) -| (P);
\draw[->,red] (P) |- (m21.east);
\draw[red] (m31.east) -| (P);
\end{tikzpicture}

\end{document}

enter image description here How should I fix it?

lucky1928
  • 4,151
  • The size of the standalone is the size of the tabular. Overlay has no size. One solution is to place the tabular inside a somewhat wider minipage. – John Kormylo Aug 15 '16 at 03:44

1 Answers1

3

You can add a horizontal space at the end of the tabular. Below I added \hspace*{15pt} which yields:

enter image description here

Notes:

Code:

\documentclass[border=5pt]{standalone}
\usepackage{tikz,booktabs,array}

\begin{document} \tikzset{>=latex}% \tikzstyle{every picture}+=[remember picture,baseline]% \tikzstyle{every node}+=[inner sep=0pt,anchor=base, minimum width=.5cm,align=center,text depth=.25ex,outer sep=1.5pt]% \tikzstyle{every path}+=[very thick]% % \newcommand{\tikzmark}[2]{\tikz \node (#1) {#2};}% % \begin{tabular}{|>{\bfseries}c|>{\bfseries}c|} \toprule \hline \tikzmark{m00}{Number} & \tikzmark{m01}{Name} \ \hline \tikzmark{m10}{0} & \tikzmark{m11}{Jack} \ \hline \tikzmark{m20}{1} & \tikzmark{m21}{Mary} \ \hline \tikzmark{m30}{2} & \tikzmark{m31}{John} \ \hline \tikzmark{m40}{3} & \tikzmark{m41}{Alice} \ \hline \bottomrule \end{tabular}% % \begin{tikzpicture}[overlay,remember picture] \coordinate (P) at ([xshift=20pt]m21.east); \draw[red] (m11.east) -| (P); \draw[->,red] (P) |- (m21.east); \draw[red] (m31.east) -| (P); \end{tikzpicture}% \hspace*{15pt}% \end{document}

Peter Grill
  • 223,288