# How to add babel captions to newfloat package environments?

This minimal example, will produce the following PDF:

\documentclass[12pt]{abntex2}
\usepackage[utf8]{inputenc}

\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext=loq,placement={!hbtp},
name=Frame,within=chapter,listname=List of Frames]{board}

\newif\ifenglish\englishfalse
% \englishtrue
\newcommand{\lang}[2]{\ifenglish#1\else#2\fi}

\ifenglish
\PassOptionsToPackage{language=english}{biblatex}
\PassOptionsToPackage{brazil,main=english,spanish,french}{babel}
\else
\PassOptionsToPackage{language=brazil}{biblatex}
\PassOptionsToPackage{main=brazil,english,spanish,french}{babel}
\fi

\begin{document}

\section{\lang{English Section}{Seção em Português}}

\listofboards*

\lang{Section contents.}{Conteúdo da seção.}

\begin{board}[htb]
\centering
\caption{\lang{Subtitle}{Legenda}}
\begin{tabular}{|c|}
\hline
\lang{Content}{Conteúdo}\\
\hline
\end{tabular}
\fonte{\lang{Author}{Autor}}
\end{board}

\end{document}


Where the captions are mixed with English. If you uncomment the lines \addto\captionsbrazil, Latex will throw the error:

LaTeX Error: \listofboardsname undefined.


I had used something like \addto\captionsbrazil on this other issue How to override command on my preamble, after its redefinition by my class with renewcommand?, and it fixed the problem. How can I use \addto\captionsbrazil with the newfloat package board environment I just created?

After reading this question The changes package and british babel: Undefined control sequence, I managed to fix it by:

1. Creating a command to hold the title of the list
2. Using that command to pass the title of the list to DeclareFloatingEnvironment
3. Using \addto\captionsbrazil{\renewcommand{\listofboardsname}
\newif\ifenglish\englishfalse

% \englishtrue
\newcommand{\lang}[2]{\ifenglish#1\else#2\fi}

\ifenglish
\PassOptionsToPackage{language=english}{biblatex}
\PassOptionsToPackage{brazil,main=english,spanish,french}{babel}
\else
\PassOptionsToPackage{language=brazil}{biblatex}
\PassOptionsToPackage{main=brazil,english,spanish,french}{babel}
\fi

\documentclass[12pt]{abntex2}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{newfloat}
\newcommand\listofboardsname{List of Frames}

\DeclareFloatingEnvironment[fileext=loq,placement={!hbtp},name=Frame,
within=chapter,listname=\listofboardsname]{board}

\begin{document}

\section{\lang{English Section}{Seção em Português}}

\listofboards

\lang{Section contents.}{Conteúdo da seção.}

\begin{board}[htb]
\centering
\caption{\lang{Subtitle}{Legenda}}
\begin{tabular}{|c|}
\hline
\lang{Content}{Conteúdo}\\
\hline
\end{tabular}
\fonte{\lang{Author}{Autor}}
\end{board}

\end{document}


References:

• There is already a predefined command for the "List of Frames", but it's not called \listofboardsname but \listboardname (since the existing one for the "List of Figures" is called \listfigurename and not \listoffiguresname). So the code in your question works fine with this replacement. – user2574 Apr 3 '19 at 19:53
• ...unfortunately this part is missing in the newfloat documentation, I just added a ticket for that: gitlab.com/axelsommerfeldt/caption/issues/51 – user2574 Apr 3 '19 at 19:57