Changing figure caption name with babel in LaTeX
mstankie opened this issue · comments
When one specifies document language and redefines figure caption name, converting Markdown to LaTeX in standalone mode, i.e:
$ pandoc -V lang=pl -M fignos-caption-name=Ilustracja -s -o doc.tex
the filter adds the following to the LaTeX document header:
%%% pandoc-fignos: required package
\usepackage{caption}
%% 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
% pandoc-fignos: change the caption name
\renewcommand{\figurename}{Ilustracja}
But the babel package, added to enable language (requested by -V lang=pl
), will overwrite the \renewcommand{\figurename}{Ilustracja}
, so the babel-default figure caption names will appear in the final PDF document.
As per Gonzalo Medina's comment (May 5, 2011 at 18:17) to the following answer: https://tex.stackexchange.com/a/17490/95312, it would be more robust to use \usepackage[figurename=<the name provided in fignos-caption-name metadata>]{caption}
instead of \renewcommand{\figurename}{<the name provided in fignos-caption-name metadata>}
.