Tabularx 的交叉引用和标题?

Tabularx 的交叉引用和标题?
\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}.

b

\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}

相关内容