这是这个问题我将使用答案中提供的表格:
\documentclass{article}
\usepackage{subcaption}
\DeclareCaptionSubType*{table}
\captionsetup[subtable]{labelformat=simple}% no parens
\renewcommand{\thesubtable}{\thetable\alph{subtable}} % added <<<<<<<<
\begin{document}
\begin{table}[ht!]
\centering
\begin{subtable}{0.3\textwidth}
\centering
\begin{tabular}{cc}
a&b\\
c&d
\end{tabular}
\caption{sub one}
\end{subtable}
\begin{subtable}{0.3\textwidth}
\centering
\begin{tabular}{cc}
a&b\\
c&d
\end{tabular}
\caption{sub two}
\end{subtable}
\caption{Two sub--tables caption}
\end{table}
\begin{table}[ht!]
\centering
\begin{subtable}{0.3\textwidth}
\centering
\begin{tabular}{cc}
w&x\\
y&z
\end{tabular}
\caption{}\label{subt:t2a}
\end{subtable}
\begin{subtable}{0.3\textwidth}
\centering
\begin{tabular}{cc}
w&x\\
y&z
\end{tabular}
\caption{}\label{subt:t2b}
\end{subtable}
\caption{ As shown in \ref{subt:t2a} and in \ref{subt:t2b}...}
\end{table}
\end{document}
这会生成如下表格(同样取自答案):
但是,我想要的是子表的标题中包含单词“Table”,并且没有父表的标题。另外,我想在标题中的表 ID 后插入一个句号,但在文本中引用表时不插入句号。以下是我想要的 Word 中的示意图:
我怎样才能实现这个目标?
答案1
以下内容是否满足您的格式需求?
\documentclass{article}
\usepackage{subcaption}
\DeclareCaptionLabelFormat{myformat}{\tablename\ #2}
\captionsetup[subtable]{labelformat=myformat,labelsep=period}
\renewcommand{\thesubtable}{\thetable\alph{subtable}}
\makeatletter
\renewcommand\p@subtable{} % no prefix string in cross-references
\makeatletter
\usepackage[noabbrev]{cleveref} % optional, for '\cref' macro
\begin{document}
\begin{table}[ht]
\centering
\begin{subtable}{0.3\textwidth}
\centering
\begin{tabular}{cc} a&b\\c&d \end{tabular}
\caption{Sub one} \label{tab:xx}
\end{subtable}
\begin{subtable}{0.3\textwidth}
\centering
\begin{tabular}{cc} e&f\\g&h \end{tabular}
\caption{Sub two} \label{tab:yy}
\end{subtable}
\end{table}
As shown in \cref{tab:xx,tab:yy}, \dots
\end{document}