TeX - LaTeX Asked on February 15, 2021
In my MWE below, I apply leandriis’s excellent recipe for creating subschemes using the chemmacros
, cleveref
, and subcaption
packages.
In my scheme captions, I would like to refer to the subschemes using the subref
command. How can I make the parts be referred to as (a) and (b), as when I refer to subfigures using 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}renewcommandthesubscheme{theschemealph{subscheme}}}
usepackage{xpatch}
makeatletter
xapptocmd{@chapter}{addtocontents{los}{protectaddvspace{10p@}}}{}{}
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.03textwidth}
includegraphics[width=textwidth]{example-image-a}%
phantomsubcaptionlabel{fig:myfigure:a}
end{subfigure}%
begin{subfigure}{0.03textwidth}
includegraphics[width=textwidth]{example-image-b}%
phantomsubcaptionlabel{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.03textwidth}
includegraphics[width=textwidth]{example-image-a}%
phantomsubcaptionlabel{sch:myscheme:a}
end{subscheme}%
begin{subscheme}{0.03textwidth}
includegraphics[width=textwidth]{example-image-b}%
phantomsubcaptionlabel{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}
Change
renewcommandthesubscheme{theschemealph{subscheme}}
to
renewcommandthesubscheme{alph{subscheme}}
renewcommandp@subscheme{thescheme}
Full example
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}
renewcommandthesubscheme{alph{subscheme}}
renewcommandp@subscheme{thescheme}
}
makeatother
usepackage{xpatch}
makeatletter
xapptocmd{@chapter}{addtocontents{los}{protectaddvspace{10p@}}}{}{}
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.03textwidth}
includegraphics[width=textwidth]{example-image-a}%
phantomsubcaptionlabel{fig:myfigure:a}
end{subfigure}%
begin{subfigure}{0.03textwidth}
includegraphics[width=textwidth]{example-image-b}%
phantomsubcaptionlabel{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.03textwidth}
includegraphics[width=textwidth]{example-image-a}%
phantomsubcaptionlabel{sch:myscheme:a}
end{subscheme}%
begin{subscheme}{0.03textwidth}
includegraphics[width=textwidth]{example-image-b}%
phantomsubcaptionlabel{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}
Correct answer by muzimuzhi Z on February 15, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP