![表のヘッダーを説明する矢印](https://rvso.com/image/392323/%E8%A1%A8%E3%81%AE%E3%83%98%E3%83%83%E3%83%80%E3%83%BC%E3%82%92%E8%AA%AC%E6%98%8E%E3%81%99%E3%82%8B%E7%9F%A2%E5%8D%B0.png)
でこれStackOverflow の回答では、以下の図を見ることができます。
これを Tikz でどのように行うのか知りたいです。ボックスは表示せず、ヘッダーのすぐ下の値を指す矢印を表示したいのですが、作業の基盤があれば、おそらくこれらの詳細は管理できるでしょう。
答え1
これを描くのは難しくありませんが、スクリーンショットからこれらすべてを入力するのは面倒です (そのため、私は単にcan 1
などを追加しました。これらのテキストは、より適切と思われるものに置き換えることができます)。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{fit,positioning}
\begin{document}
\begin{tikzpicture}[font=\sffamily,node distance=2pt and 4pt]
\begin{scope}[local bounding box=top]
\node (c1) {d};
\node[right=of c1] (c2) {l};
\node[fit=(c1) (c2),label=above:type]{};
\node[right=1cm of c2] (c3) {r};
\node[right=of c3] (c4) {w};
\node[right=of c4] (c5) {x};
\node[fit=(c3) (c5),label=above:users]{};
\node[right=1cm of c5] (c6) {r};
\node[right=of c6] (c7) {w};
\node[right=of c7] (c8) {x};
\node[fit=(c6) (c8),label=above:groups]{};
\node[right=1cm of c8] (c9) {r};
\node[right=of c9] (c10) {w};
\node[right=of c10] (c11) {x};
\node[fit=(c9) (c11),label=above:others]{};
\end{scope}
\foreach \X [count=\Y,evaluate=\Y as \Z using {int(12-\Y)},
remember=\Z as \LastZ]
in {can 1,can 2,can 3,can 4,can 5,can 6,can 7,can 8,can 9,can 10,can 11}
{\ifnum\Y=1
\node[anchor=north west] (l\Z) at ([xshift=1em,yshift=-1ex]top.south east)
{\X};
\else
\node[anchor=north west] (l\Z) at ([yshift=-0.2ex]l\LastZ.south west) {\X};
\fi
\draw[latex-] (c\Z) |- (l\Z);
}
\end{tikzpicture}
\end{document}
答え2
\tablenotes
私は、色と組み合わせたfromのみを使用する、まったく異なるレイアウトを提案しますthreeparttable
。これは、私の意見では、矢印と同じくらい表現力豊かです。
\documentclass[11pt]{article}
\usepackage{array, threeparttable, booktabs}
\usepackage[svgnames]{xcolor}
\newcommand{\dir}{\textcolor{Goldenrod}d}
\newcommand{\syl}{\textcolor{LightSteelBlue}l}
\newcommand{\rd}{\textcolor{Salmon}r}
\newcommand{\wri}{\textcolor{Gold}w}
\newcommand{\exc}{\textcolor{YellowGreen}x}
\begin{document}
\begin{table}[!htbp]
\centering\sffamily
\begin{threeparttable}
\caption{Table}
\label{}
\begin{tabular}{*{4} {>{\centering\arraybackslash}p{1.2cm}}}
\toprule
type & users & group & others \\
\cmidrule(lr){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}
\dir \enspace\syl & \rd\enspace\wri\enspace\exc & \rd\enspace\wri\enspace\exc& \rd\enspace\wri\enspace\exc \\
\bottomrule
\end{tabular}
\smallskip
\begin{tablenotes}[flushleft, online]\small
\item[\dir\rlap{:}] Is a directory.
\item[\syl: ] Is a symbolic link.
\item[\rd: ] Can Read,\, Read files.
\item[\wri: ] $\!\!$Can Write,\, Create files.
\item[\exc: ] Can Execute,\, List files.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}