在此 MWE 中,我想将子标题标签改为Figure 0.1(a)
。(a)
换句话说,我需要将整个子标题改为Figure 0.1(a) some subcaption
。
此外,如果父图形标签发生变化,我需要子标题标签也随之改变(例如,Fig 1
父图形的标签改变Fig 1(a)
为子图形的标签改变)。
\documentclass{scrreprt}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\textwidth]{example-image-a}
\subcaption{some subcaption}
\end{subfigure}
\caption{some caption}
\end{figure}
\end{document}
答案1
该\DeclareCaptionFormat
命令将在这里提供帮助,#1
和#2
按此#3
顺序被标题标签、分隔符和标题文本替换。
\documentclass{scrreprt}
\usepackage{graphicx}
\usepackage{subcaption}
\DeclareCaptionFormat{diaa}{\figurename~ \thefigure.#1 #2 #3}
\begin{document}
\captionsetup[subfigure]{format=diaa}
\chapter{Foo}
\begin{figure}
\centering
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\textwidth]{example-image-a}
\subcaption{some subcaption}
\end{subfigure}
\caption{some caption}
\end{figure}
\end{document}
更新通过一些“参数化”\@captype
\documentclass{scrreprt}
\usepackage{graphicx}
\usepackage{subcaption}
\makeatletter
\DeclareCaptionFormat{diaa}{\csname\@captype name\endcsname\ \csname the\@captype\endcsname.#1 #2 #3}
\makeatother
\begin{document}
\captionsetup[subfigure]{format=diaa}
\captionsetup[subtable]{format=diaa}
\chapter{Foo}
\begin{figure}
\centering
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=\textwidth]{example-image-a}
\subcaption{some subcaption}
\end{subfigure}
\caption{some caption}
\end{figure}
\begin{table}
\centering
\begin{subtable}{0.5\textwidth}
\subcaption{some subcaption}
\end{subtable}
\caption{some caption to a table}
\end{table}
\end{document}