![Tabularx 的交叉引用和标题?](https://linux22.com/image/446462/Tabularx%20%E7%9A%84%E4%BA%A4%E5%8F%89%E5%BC%95%E7%94%A8%E5%92%8C%E6%A0%87%E9%A2%98%EF%BC%9F.png)
\documentclass[12pt]{article}
\usepackage{float}
\usepackage{tabularx}
\title{Tabularx Test}
\begin{document}
\maketitle
\begin{center}
\begin{tabularx}{100pt}{c|c|c|}
\multicolumn{1}{c}{ } &\multicolumn{1}{c}{$\omega_1$} &\multicolumn{1}{c}{$\omega_2$} \\
\cline{2-3}
$a$ & 0 & 0 \\ \cline{2-3}
$b$ & $x$ & $y$ \\ \cline{2-3}
\end{tabularx}\vskip 1cm
\captionof{Figure}{test}
\label{twobytwo}
\end{center}
\end{document}
经过一番搜索,我认为 \captionof 可以与 tabularx 配合使用。但代码不起作用。我想让标题和交叉引用起作用。非常感谢!
答案1
该问题与tabularx
使用\captionof{table}{...}
(并添加包caption
)你可以编写
See the table \ref{twobytwox} or table \ref{twobytwo}.
\documentclass[12pt]{article}
\usepackage{float}
\usepackage{tabularx}
\usepackage{caption}% added <<<<<
\title{Tabularx and Tabular Test}
\begin{document}
\maketitle
\begin{center}
\begin{tabularx}{100pt}{c|c|c|}
\multicolumn{1}{c}{ } &\multicolumn{1}{c}{$\omega_1$} &\multicolumn{1}{c}{$\omega_2$} \\
\cline{2-3}
$a$ & 0 & 0 \\ \cline{2-3}
$b$ & $x$ & $y$ \\ \cline{2-3}
\end{tabularx}
\smallskip
\captionof{table}{test tabularx}
\label{twobytwox}
\end{center}
\begin{center}
\begin{tabular}{c|c|c|}
\multicolumn{1}{c}{ } &\multicolumn{1}{c}{$\omega_1$} &\multicolumn{1}{c}{$\omega_2$} \\
\cline{2-3}
$a$ & 0 & 0 \\ \cline{2-3}
$b$ & $x$ & $y$ \\ \cline{2-3}
\end{tabular}
\smallskip
\captionof{table}{test only tabular}
\label{twobytwo}
\end{center}
See the table \ref{twobytwox} or table \ref{twobytwo}.
\end{document}