我需要更改第二个图和两个子图的计数器。对于图,它有效,但对于子图无效。非常感谢
\documentclass[]{article}
\usepackage{subcaption}
\begin{document}
\begin{figure}[h]
\caption{new}
\end{figure}
\begin{figure}[ht]
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure A}
\end{subfigure}
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure B}
\end{subfigure} \caption{new}
\end{figure}
\addtocounter{figure}{-1} %works
\addtocounter{subfigure}{+2} %doesnt work
\begin{figure}[htb]
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure should be c instead of a, addtocounter for subfigure doesnt work}
\end{subfigure}
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure should be d instead of b, addtocounter for subfigure doesnt work}
\end{subfigure}
\caption{number should like the figure before, addtocounter for figure works}
\end{figure}
\end{document}
答案1
你需要把你的添加物放到subfigure
柜台上里面第一个子图:
\documentclass[]{article}
\usepackage{subcaption}
\begin{document}
\begin{figure}[h]
\caption{new}
\end{figure}
\begin{figure}[ht]
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure A}
\end{subfigure}
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure B}
\end{subfigure} \caption{new}
\end{figure}
\addtocounter{figure}{-1} %works
\addtocounter{subfigure}{2} % doesn't work here
\begin{figure}[htb]
\begin{subfigure}[t]{.45\linewidth}
\addtocounter{subfigure}{2} % works here
\caption{ subfigure should be c instead of a, addtocounter for subfigure doesnt work}
\end{subfigure}
\begin{subfigure}[t]{.45\linewidth}
\caption{subfigure should be d instead of b, addtocounter for subfigure doesnt work}
\end{subfigure}
\caption{number should like the figure before, addtocounter for figure works}
\end{figure}
\end{document}