如何交叉引用表中的列名?

如何交叉引用表中的列名?

我的乳膠文件中有一個相當大的表格,並且在表格隨附的文本中,我想聲明如下內容:

如表 III 的 A 列所示,它是...

我知道如何交叉引用表,但如何交叉引用列名?我想要這樣做的原因是列名稱可能會更改,並且我不想在文件中搜尋我使用列名稱的所有實例。

我的表格的簡化版本如下:

\begin{table}[htbp]
\caption{The caption}
\label{tbl:data}
\tiny
\begin{tabularx}{\columnwidth}{l X c c c c c}
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} & \textbf{E} & \# Changed &F\\
\hline
\multirow{4}{*}{X} & X1 & 1 & 2 & 3 & 4 & 5\\
& X2 & 6 & 7 & 8 & 9 &\\
& X3 & 10 & 11 & 12 & 13 & 14\\
& X4 & 15 & 16 & 17 & 18 & 19\\
\hline
\end{tabularx}
\end{table}

答案1

這是一個適用於“任何”列標題的版本,將假標籤寫入.aux並用 引用它\nameref*

如果列標題只是 pureA等,另一種基於計數器的方法會更好!

\documentclass{article}

\usepackage{tabularx}
\usepackage{multirow}

\newcommand{\columnheaddisplaystyle}[1]{%
  \textbf{#1}%
}

\makeatletter
\newcommand{\labelthis}[2]{%
  \columnheaddisplaystyle{#2}%
  \immediate\write\@auxout{%
    \string\newlabel{#1}{{}{}{#2}{}}
  }%
}

\usepackage{hyperref}

\makeatletter


\begin{document}

\begin{table}[htbp]
\caption{The caption} 
\label{tbl:data}
\tiny
\begin{tabularx}{\columnwidth}{l X c c c c c}
\labelthis{mycolumn}{A}  & \textbf{B} & \textbf{C} & \textbf{D} & \textbf{E} & \# Changed &F\\
\hline
\multirow{4}{*}{X} & X1 & 1 & 2 & 3 & 4 & 5\\
& X2 & 6 & 7 & 8 & 9 &\\
& X3 & 10 & 11 & 12 & 13 & 14\\
& X4 & 15 & 16 & 17 & 18 & 19\\
\hline
\end{tabularx}
\end{table}

As presented in column \nameref*{mycolumn} in Table \ref{tbl:data}, it is ...

\end{document}

相關內容