0

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}

% \addto\captionsbrazil{\renewcommand{\boardname}{Quadro}}
% \addto\captionsbrazil{\renewcommand{\listofboardsname}{Lista de Quadros}}

\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}

enter image description here

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?

1

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}

\addto\captionsbrazil{\renewcommand{\boardname}{Quadro}}
\addto\captionsbrazil{\renewcommand{\listofboardsname}{Lista de Quadros}}

\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:

  1. Why doesn't LaTeX hyphenate words containing accents, e.g. "développement"?
  2. Remove List of [newfloat] from TOC
  • 1
    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. – Axel Sommerfeldt Apr 3 at 19:53
  • 1
    ...unfortunately this part is missing in the newfloat documentation, I just added a ticket for that: gitlab.com/axelsommerfeldt/caption/issues/51 – Axel Sommerfeldt Apr 3 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.