在下面的 MWE 中,我应用leandriis 的绝妙食谱使用创建子方案chemmacros
,cleveref
, 和subcaption
包。
在我的方案标题中,我想使用命令引用子方案\subref
。如何才能使各部分被称为 (a) 和 (b),就像我使用 引用子图时一样\subref
?
\documentclass[oneside,11pt]{book}
\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage[
expansion = false ,
tracking = smallcaps ,
letterspace = 40 ,
]{microtype}
\usepackage{booktabs}
\usepackage{acro}
\acsetup{
barriers/use, barriers/reset,
use-id-as-short,
}
\usepackage{chemformula}
\setchemformula{charge-hshift=.5pt}
\usepackage{chemmacros}
\usechemmodule{scheme}
\usepackage{graphicx}
\usepackage[titles]{tocloft}
\setlength{\cftfignumwidth}{2.9em}
\setlength{\cfttabnumwidth}{2.9em}
\AtEndPreamble{\DeclareCaptionSubType*{scheme}\counterwithin{scheme}{chapter}\renewcommand\thesubscheme{\thescheme\alph{subscheme}}}
\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}{\addtocontents{los}{\protect\addvspace{10\p@}}}{}{}
\makeatother
\usepackage[capitalize]{cleveref}
\crefformat{subscheme}{\schemename~#2#1#3}
\begin{document}
\tableofcontents
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\addcontentsline{toc}{chapter}{\listschemename}
\listofschemes
\chapter{First chapter}
% Example subfigure
\begin{figure}[!h]
\centering
\begin{subfigure}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-a}%
\phantomsubcaption\label{fig:myfigure:a}
\end{subfigure}%
\begin{subfigure}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-b}%
\phantomsubcaption\label{fig:myfigure:b}
\end{subfigure}%
\caption{Caption of second figure.
Part \subref{fig:myfigure:a} and part \subref{fig:myfigure:b}.}\label{fig:myfigure}
\end{figure}
% Example subscheme
\begin{scheme}[!h]
\centering
\begin{subscheme}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-a}%
\phantomsubcaption\label{sch:myscheme:a}
\end{subscheme}%
\begin{subscheme}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-b}%
\phantomsubcaption\label{sch:myscheme:b}
\end{subscheme}%
\caption{Caption of third scheme.
Part \subref{sch:myscheme:a} and part \subref{sch:myscheme:b}.}\label{sch:myscheme}
\end{scheme}
Refer to \cref{fig:myfigure}, \cref{fig:myfigure:a}, and \cref{fig:myfigure:b}.
Finally refer to \cref{sch:myscheme}, \cref{sch:myscheme:a}, and \cref{sch:myscheme:b}.
\end{document}
答案1
改变
\renewcommand\thesubscheme{\thescheme\alph{subscheme}}
到
\renewcommand\thesubscheme{\alph{subscheme}}
\renewcommand\p@subscheme{\thescheme}
完整示例
\documentclass[oneside,11pt]{book}
%\usepackage[semibold,tt=false]{libertine}
%\usepackage{libertinust1math}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage[
expansion = false ,
tracking = smallcaps ,
letterspace = 40 ,
]{microtype}
%\usepackage{booktabs}
%\usepackage{acro}
%\acsetup{
% barriers/use, barriers/reset,
% use-id-as-short,
%}
\usepackage{chemformula}
\setchemformula{charge-hshift=.5pt}
\usepackage{chemmacros}
\usechemmodule{scheme}
\usepackage{graphicx}
\usepackage[titles]{tocloft}
\setlength{\cftfignumwidth}{2.9em}
\setlength{\cfttabnumwidth}{2.9em}
\makeatletter
\AtEndPreamble{
\DeclareCaptionSubType*{scheme}
\counterwithin{scheme}{chapter}
\renewcommand\thesubscheme{\alph{subscheme}}
\renewcommand\p@subscheme{\thescheme}
}
\makeatother
\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}{\addtocontents{los}{\protect\addvspace{10\p@}}}{}{}
\makeatother
\usepackage[capitalize]{cleveref}
\crefformat{subscheme}{\schemename~#2#1#3}
\begin{document}
\tableofcontents
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\addcontentsline{toc}{chapter}{\listschemename}
\listofschemes
\chapter{First chapter}
% Example subfigure
\begin{figure}[!h]
\centering
\begin{subfigure}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-a}%
\phantomsubcaption\label{fig:myfigure:a}
\end{subfigure}%
\begin{subfigure}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-b}%
\phantomsubcaption\label{fig:myfigure:b}
\end{subfigure}%
\caption{Caption of second figure.
Part \subref{fig:myfigure:a} and part \subref{fig:myfigure:b}.}\label{fig:myfigure}
\end{figure}
% Example subscheme
\begin{scheme}[!h]
\centering
\begin{subscheme}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-a}%
\phantomsubcaption\label{sch:myscheme:a}
\end{subscheme}%
\begin{subscheme}{0.03\textwidth}
\includegraphics[width=\textwidth]{example-image-b}%
\phantomsubcaption\label{sch:myscheme:b}
\end{subscheme}%
\caption{Caption of third scheme.
Part \subref{sch:myscheme:a} and part \subref{sch:myscheme:b}.}\label{sch:myscheme}
\end{scheme}
Refer to \cref{fig:myfigure}, \cref{fig:myfigure:a}, and \cref{fig:myfigure:b}.
Finally refer to \cref{sch:myscheme}, \cref{sch:myscheme:a}, and \cref{sch:myscheme:b}.
\end{document}