
我想更新figure
環境,因為我希望標題Supplementary Figure
改為Figure
。我正在使用nature
文檔類別並找到了程式碼片段:
\renewenvironment{figure}{\let\caption\NAT@figcaption}{}
\newcommand{\NAT@figcaption}[2][]{\AtEndDocument{%
\refstepcounter{figure}
\ifthenelse{\value{figure}=1}{
\newpage\noindent%
% \rule{\textwidth}{1pt}
}{
\par\vfill
}
\sffamily\noindent\textbf{Figure \arabic{figure}}\hspace{1em}#2}
}
在裡面nature.cls
。我的想法是包含程式碼
\renewenvironment{figure}{\let\caption\NAT@figcaption}{}
\renewcommand{\NAT@figcaption}[2][]{\AtEndDocument{%
\refstepcounter{figure}
\ifthenelse{\value{figure}=1}{
\newpage\noindent%
% \rule{\textwidth}{1pt}
}{
\par\vfill
}
\sffamily\noindent\textbf{Supplementary Figure \arabic{figure}}\hspace{1em}#2}
}
在我的文檔中,但顯然,這是行不通的。有沒有辦法只針對特定文件更改圖形環境?
答案1
你的補丁在這裡運作得很好:
\documentclass{nature}
\makeatletter
\renewcommand{\NAT@figcaption}[2][]{\AtEndDocument{%
\refstepcounter{figure}
\ifthenelse{\value{figure}=1}{
\newpage\noindent%
% \rule{\textwidth}{1pt}
}{
\par\vfill
}
\sffamily\noindent\textbf{Supplementary Figure \arabic{figure}}\hspace{1em}#2}
}
\makeatother
\begin{document}
Some text
\begin{figure}
\caption{A figure}
\end{figure}
\end{document}
結果是:“補充圖1A圖”
由於您只向我們提供了程式碼片段而不是完整的文件(MWE),因此很難判斷您做錯了什麼。