我怎样才能在每个表格元素的角落插入一些参考资料,以便我可以引用其中的文本?这是当前产品:
\newcommand{\RowSize}{3cm}
\begin{table}[]
\centering
\begin{tabular}{|p{\RowSize}|p{\RowSize}|p{\RowSize}|}
\hline
One & Two & Three \\
\hline
Four & \cellcolor[HTML]{9B9B9B} & \cellcolor[HTML]{9B9B9B} \\
\hline
Seven & Eight & Nine \\
\hline
\end{tabular}
\end{table}
这就是我想去的地方
答案1
你或许可以做这样的事情:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{etoolbox} % for \AtBeginEnvironment
\usepackage{alphalph} % should you need more than 26 labels in a table
\newcounter{CL} % make a new counter for cell labels
\newcommand\CL{\refstepcounter{CL}\hfill\AlphAlph{\value{CL}}} % \CL will increase the counter and print its value as a capital letter
\newcommand{\RowSize}{3cm}
\AtBeginEnvironment{tabular}{\setcounter{CL}{0}} % reset counter at every tabular
\begin{document}
\begin{table}
\centering
\begin{tabular}{|p{\RowSize}|p{\RowSize}|p{\RowSize}|}
\hline
One \CL & Two \CL & Three \CL \\
\hline
Four \CL & \cellcolor[HTML]{9B9B9B} & \cellcolor[HTML]{9B9B9B} \\
\hline
Seven \CL& Eight \CL & Nine \CL \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
以下内容可能有用。标签的位置始终位于单元格的右上角。如果\labelcell
在任何内容之前使用,内容将向下移动一行。如果在内容之后使用它,内容将不会移动。这是宏的一个有趣的副作用,\label
我认为在这种情况下对于包含大量内容的单元格非常有用。不过,内容的垂直偏移仅出现在p
-type 列中。
\documentclass[]{article}
\usepackage{duckuments}
\usepackage{alphalph}
\usepackage[table]{xcolor}
\newcounter{labelcellcount}[table]
%% appearance how it is put at the end of the cell
\newcommand\incelllabelcellcount
{%
\llap{\textcolor{gray}{\thelabelcellcount}}%
}
%% overall appearance of the counter
\renewcommand\thelabelcellcount
{%
\AlphAlph{\value{labelcellcount}}%
}
\newcommand\labelcell[1]
{%
\refstepcounter{labelcellcount}%
\label{#1}%
\aftergroup\incelllabelcellcount
}
\begin{document}
\newcommand{\RowSize}{3cm}
\begin{tabular}{|p{\RowSize}|p{\RowSize}|p{\RowSize}|}
\hline
\labelcell{cell:one} \blindduck & \labelcell{cell:two}Two &
\labelcell{cell:three}Three \\
\hline
Four\labelcell{cell:four} & \cellcolor[HTML]{9B9B9B} & \cellcolor[HTML]{9B9B9B} \\
\hline
Seven\labelcell{cell:seven} & Eight\labelcell{cell:eight} &
Nine\labelcell{cell:nine} \\
\hline
\end{tabular}
\end{document}