図 環境 自然 ドキュメント クラスを更新

図 環境 自然 ドキュメント クラスを更新

figureキャプションSupplementary Figureを の代わりに にしたいので、環境を更新したいと思いますFigure。私は documentclass を使用しており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}

結果は「補足図1 A図」

完全なドキュメント (MWE) ではなくコード スニペットのみが提供されたため、何が間違っているのかを判断するのは困難です。

関連情報