这个最小的例子将产生以下 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}
其中captions
和 英语 混杂在一起。如果取消注释这些行\addto\captionsbrazil
,Latex 将抛出错误:
LaTeX Error: \listofboardsname undefined.
我曾经\addto\captionsbrazil
在另一个问题上使用过类似的东西在我的类使用 renewcommand 重新定义序言中的命令之后,如何覆盖它?,问题就解决了。我该如何将其\addto\captionsbrazil
与newfloat
刚刚创建的包板环境一起使用?
答案1
读完这个问题后更改包和英国 babel:未定义的控制序列,我设法通过以下方式修复它:
- 创建一个命令来保存列表的标题
- 使用该命令将列表标题传递给
DeclareFloatingEnvironment
- 使用
\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}
参考: