TransWikia.com

Renew Figure Environment Nature Documentclass

TeX - LaTeX Asked by clearseplex on August 14, 2021

I want to renew the figure environment because I want the caption to be Supplementary Figure instead of Figure.
I am using the nature documentclass and found the code snippet:

renewenvironment{figure}{letcaptionNAT@figcaption}{}
    
newcommand{NAT@figcaption}[2][]{AtEndDocument{%
    refstepcounter{figure}
    ifthenelse{value{figure}=1}{
        newpagenoindent%
%        rule{textwidth}{1pt}
    }{
        parvfill
    }
    sffamilynoindenttextbf{Figure arabic{figure}}hspace{1em}#2}
    }

in the nature.cls.
My idea was to include the code

renewenvironment{figure}{letcaptionNAT@figcaption}{}
renewcommand{NAT@figcaption}[2][]{AtEndDocument{%
    refstepcounter{figure}
    ifthenelse{value{figure}=1}{
        newpagenoindent%
%        rule{textwidth}{1pt}
    }{
        parvfill
    }
    sffamilynoindenttextbf{Supplementary Figure arabic{figure}}hspace{1em}#2}
    }

in my document but obviously, that does not work.
Is there a way to change the figure environment just for the particular document?

One Answer

Your patch works fine here:

documentclass{nature}

makeatletter
renewcommand{NAT@figcaption}[2][]{AtEndDocument{%
    refstepcounter{figure}
    ifthenelse{value{figure}=1}{
        newpagenoindent%
%        rule{textwidth}{1pt}
    }{
        parvfill
    }
    sffamilynoindenttextbf{Supplementary Figure arabic{figure}}hspace{1em}#2}
    }
makeatother

begin{document}
Some text
begin{figure}
caption{A figure}
end{figure}
end{document}

The result is: "Supplementary Figure 1 A figure"

Since you have given us only code snippets instead of a complete document (MWE) it's hard to tell what you have done wrong.

Correct answer by user205700 on August 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP