tomduck / pandoc-fignos

A pandoc filter for numbering figures and figure references.
GNU General Public License v3.0
329 stars 25 forks source link

! LaTeX Error: Environment fignos:no-prefix-figure-caption undefined. #88

Open kleinbottle opened 3 years ago

kleinbottle commented 3 years ago

This issue has been dealt with before here.

I am using a default file that invokes pandoc-eqnos and pandoc-fignos ahead of citeproc. I also have \usepackage{caption} in my 'header-includes` file.

When I try to generate PDF on a somewhat long file, I get the error message:

! LaTeX Error: Environment fignos:no-prefix-figure-caption undefined.

along with

%% pandoc-fignos: environment to disable figure caption prefixes
    \makeatletter
    \newcounter{figno}
    \newenvironment{fignos:no-prefix-figure-caption}{
      \caption@ifcompatibility{}{
        \let\oldthefigure\thefigure
        \let\oldtheHfigure\theHfigure
        \renewcommand{\thefigure}{figno:\thefigno}
        \renewcommand{\theHfigure}{figno:\thefigno}
        \stepcounter{figno}
        \captionsetup{labelformat=empty}
      }
    }{
      \caption@ifcompatibility{}{
        \captionsetup{labelformat=default}
        \let\thefigure\oldthefigure
        \let\theHfigure\oldtheHfigure
        \addtocounter{figure}{-1}
      }
    }
    \makeatother

If I copy the above text from makeatletter to makeatother and include it in the header-includes file, I get the required PDF file.

Is this the way it is meant to be? Or is there a cleaner workaround? Or am I doing something wrong?

bidspells commented 2 years ago

I believe this behavior is "OK" as it is caused by pandoc. There is a respective note in pandoc-fignos documentation: "A word of warning: Pandoc-fignos's additions to the header-includes are overridden when pandoc's --include-in-header option is used. This is owing to a https://github.com/jgm/pandoc/issues/3139 in pandoc. Users may choose to deliberately override pandoc-fignos's header-includes by providing their own LaTeX through --include-in-header. If a user needs to include other bits of LaTeX in this way, then they will need to do the same for the LaTeX that pandoc-fignos needs."

johannesmols commented 1 year ago

I got this error when I forgot to include {#fig:id} behind an image declaration.

gmarxcc commented 1 year ago

I got this error when I forgot to include {#fig:id} behind an image declaration.

Yes, I just forgot to add the {#fig:id} syntax, and the compilation process gives me the same error. After adding the {#fig:id} to all the instances, the compilation was successful.