Tikz 表格及参考

Tikz 表格及参考

单元格内有参考的表格

我需要绘制一个带有相同箭头的表格。我不想使用图形软件的原因是我需要使用 latex 在单元格内添加动态引用。如果有人能帮助我,我将不胜感激。

答案1

您可以使用矩阵来创建表格,对于箭头,有shapes.symbols。并且fitbackgroundscalc允许您动态调整这些内容。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{matrix,fit,backgrounds,calc,shapes.symbols}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
 \matrix[matrix of nodes,row sep=-\pgflinewidth,column sep=-\pgflinewidth,
 standard size/.style={minimum height=6mm,text width=pi*1cm,anchor=center},
 nodes={draw,standard size,fill=white},
 row 1/.style={nodes={standard size,fill=purple,text=white}},]
 (mat)
 { aaa & bbb & ccc \\ 
  aaa & bbb & ccc \\ 
   |[fill=red,text=white]| aaa & bbb & ccc \\ 
   aaa & bbb & ccc \\ 
   |[fill=red,text=white]| aaa & |[fill=blue,text=white]|  bbb & |[fill=red,text=white]|  ccc \\ 
   aaa & bbb & ccc \\ 
  }; 
 \begin{scope}[on background layer]
  \node[fit=(mat),inner sep=8mm,fill=cyan!50!gray,rounded corners=8pt](fit){};
 \end{scope}
 \foreach \X/\Y [count=\Z] in {AAA/orange,BBB/green!80!gray,CCC/cyan!50!gray}
 {\path let \p1=($(mat-1-\Z.north east)-(mat-1-\Z.north west)$),
 \p2=($(fit.north)-(mat-1-\Z.north west)$)
 in node[shape=signal,signal to=east,signal from=west,
 anchor=south west,fill=\Y,
 minimum width=\x1+\y2/2-\pgflinewidth,minimum height=\y2-2*\pgflinewidth]
 at (mat-1-\Z.north west) {\X};}
\end{tikzpicture}
\end{document}

在此处输入图片描述

当然,它可以与“开箱即用”的参考/链接一起使用。

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{matrix,fit,backgrounds,calc,shapes.symbols}
\usepackage{hyperref}
\begin{document}
\begin{figure}[htb]
\begin{tikzpicture}[font=\sffamily]
 \matrix[matrix of nodes,row sep=-\pgflinewidth,column sep=-\pgflinewidth,
 standard size/.style={minimum height=6mm,text width=pi*1cm,anchor=center},
 nodes={draw,standard size,fill=white},
 row 1/.style={nodes={standard size,fill=purple,text=white}},]
 (mat)
 { aaa \cite{Einstein} & bbb & ccc \\ 
  aaa \cite{Witten:1982fp} & bbb & ccc \\ 
   |[fill=red,text=white]| aaa \cite{AlvarezGaume:1983ig} & bbb & ccc \\ 
   aaa & bbb & ccc \\ 
   |[fill=red,text=white]| aaa & |[fill=blue,text=white]|  bbb & |[fill=red,text=white]|  ccc \\ 
   aaa & bbb & ccc \\ 
  }; 
 \begin{scope}[on background layer]
  \node[fit=(mat),inner sep=8mm,fill=cyan!50!gray,rounded corners=8pt](fit){};
 \end{scope}
 \foreach \X/\Y [count=\Z] in {AAA/orange,BBB/green!80!gray,CCC/cyan!50!gray}
 {\path let \p1=($(mat-1-\Z.north east)-(mat-1-\Z.north west)$),
 \p2=($(fit.north)-(mat-1-\Z.north west)$)
 in node[shape=signal,signal to=east,signal from=west,
 anchor=south west,fill=\Y,
 minimum width=\x1+\y2/2-\pgflinewidth,minimum height=\y2-2*\pgflinewidth]
 at (mat-1-\Z.north west) {\X};}
\end{tikzpicture}
\caption{A Ti\emph{k}Zy table.}
\label{tab:TikZy}
\end{figure}


\begin{thebibliography}{9}
\bibitem{Einstein} 
A.~Einstein, \textit{Zur Elektrodynamik bewegter K{\"o}rper}, 
Annalen der Physik, 322(10):891--921, 1905.

\bibitem{Witten:1982fp}
  E.~Witten, \textit{An SU(2) Anomaly},
  Phys.\ Lett.\ B \textbf{117}, 324  (1982).

\bibitem{AlvarezGaume:1983ig} 
  L.~Alvarez--Gaum\'{e} and E.~Witten,
  \textit{Gravitational Anomalies},
  Nucl.\ Phys.\ B \textbf{234}, 269 (1984).
\end{thebibliography}
\end{document}

在此处输入图片描述

相关内容