tikz 在独立文档类中剪辑的表格图像上绘制

tikz 在独立文档类中剪辑的表格图像上绘制

我一直认为独立版会在中心显示我的绘图,但下面的示例似乎被剪裁了(红线)。

\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}

在此处输入图片描述 我该如何修复它?

答案1

您可以在 末尾添加一个水平空格tabular。下面我添加了\hspace*{15pt}以下内容:

在此处输入图片描述

笔记:

代码:

\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}

相关内容