我想要引用“表 1 面板 A”,但是子表的标签就是没有被拾取:我得到了表 1 &??
\documentclass[letterpaper, 12pt]{article}
\usepackage{tabularx}
\usepackage{subcaption}
\renewcommand\subtablename{Panel}
\renewcommand{\thesubtable}{\Alph{subtable}}
\captionsetup[sub]{labelformat=simple, labelsep=colon, belowskip=12pt}
\usepackage{cleveref}
\crefname{subtable}{panel}{panels}
\Crefname{subtable}{Panel}{Panels}
\begin{document}
\begin{table}
\caption{Hello World}\label{tab:01}
\begin{subtable}{\hsize}
\caption*{Panel A: Hello}
\label{subtab:01a}
\begin{tabular}{c}
\end{tabular}
\end{subtable}
\begin{subtable}{\hsize}
\caption*{Panel B: World}
\label{subtab:01b}
\begin{tabular}{c}
\end{tabular}
\end{subtable}
\end{table}
I want to refer to "Table 1 panel A" \\
but the label of the subtable just doesn't get picked up \\
as follows: ~\Cref{tab:01}~\cref{tab:01a}
\end{document}
参见下面的输出图片:
答案1
欢迎来到 TeX.SE。我相信您想要的是以下内容:
\cref{subtab:01a}
而不是为了\cref{tab:01a}
避免输出中出现“??”(您收到一条错误消息:“LaTeX 警告:第 1 页上的引用‘tab:01a’在输入第 32 行未定义”,不要忽略错误消息!);\subcaption{Hello}
并\subcaption{World}
用\caption*{Panel A: Hello}
和\caption*{Panel B: World}
代替适当的标签;\renewcommand{\p@subtable}{}
这样\cref{subtab:01a}
和\cref{subtab:01b}
分别打印“面板 A”和“面板 B”,而不是“面板 1A”和“面板 1B”。 (如您的问题中所要求的)。
\documentclass{article}
\usepackage{subcaption}
\renewcommand{\subtablename}{Panel}
\renewcommand{\thesubtable}{\Alph{subtable}}
\captionsetup[sub]{labelformat=simple, labelsep=colon, belowskip=12pt}
\usepackage{cleveref}
\crefname{subtable}{panel}{panels}
\Crefname{subtable}{Panel}{Panels}
\makeatletter
\renewcommand{\p@subtable}{}
\makeatother
\begin{document}
\begin{table}
\caption{Hello World}\label{tab:01}
\begin{subtable}{\hsize}
\subcaption{Hello}
\label{subtab:01a}
\begin{tabular}{c}
\end{tabular}
\end{subtable}
\begin{subtable}{\hsize}
\subcaption{World}
\label{subtab:01b}
\begin{tabular}{c}
\end{tabular}
\end{subtable}
\end{table}
\Cref{tab:01}~\cref{subtab:01a}, \cref{tab:01}~\cref{subtab:01b}.
\end{document}