我使用这个文档类abntex2
来自:https://ctan.org/pkg/abntex2?lang=en,但是当我生成这个时:
\documentclass[12pt]{abntex2}
\renewcommand{\listfigurename}{Lista de Figuras}
\begin{document}
\listoffigures*
\end{document}
图形名称列表不会被覆盖Lista de Figuras
,它仍然Lista de Ilustrações
:
它仅当我将\renewcommand{\listfigurename}{Lista de Figuras}
其放入文档中时才有效:
\documentclass[12pt]{abntex2}
\begin{document}
\renewcommand{\listfigurename}{Lista de Figuras}
\listoffigures*
\end{document}
为什么我无法覆盖它?
查看abntex2
代码,我发现他们重新定义了命令:
\renewcommand{\listfigurename}{Lista de ilustra\c{c}\~{o}es}
\listfigurename
在课程包含之后,如何覆盖我的序言abntex
?
额外的
如果有人想知道我是如何在英语和葡萄牙语之间切换的,方法如下:
\documentclass[12pt]{abntex2}
\usepackage[utf8]{inputenc}
\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}}
\lang{Section contents.}{Conteúdo da seção.}
\end{document}
生成以下葡萄牙语 PDF:
答案1
你的线路有问题
\PassOptionsToPackage{brazil,main=english,spanish,french}{babel}
是来得太晚了。此时babel
已经加载了,但没有您需要的选项。您需要将以下行移至上方\documentclass{abntex2}
\PassOptionsToPackage{brazil,english}{babel} % ,spanish,french <========
请注意,我删除了 mwe 中未使用的西班牙语和法语,并且删除了main=
。我们稍后使用命令更改语言
\selectlanguage{english}
为了说明下面给出的代码biblatex
也能正常工作,我添加了小型参考书目的引用和打印......
使用完整的 MWE:
\PassOptionsToPackage{brazil,english}{babel} % ,spanish,french <========
\documentclass[12pt]{abntex2}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{graphicx}
\newif\ifenglish\englishfalse
%\englishtrue
\newcommand{\lang}[2]{\ifenglish#1\else#2\fi}
\ifenglish
\usepackage[language=english]{biblatex}
\selectlanguage{english} % <==========================================
\else
\usepackage[language=brazil]{biblatex}
\selectlanguage{brazil} % <===========================================
\fi
\addbibresource{biblatex-examples.bib}
\begin{document}
\listoffigures*
\section{\lang{English Section}{Seção em Português}}
\begin{figure}[htbp]
\centering
\includegraphics[width=5cm]{example-image-a}
\caption{test}
\label{fig:example-image-a}
\end{figure}
\lang{Section contents.}{Conteúdo da seção.}
\begin{figure}[htbp]
\centering
\includegraphics[width=5cm]{example-image-b}
\caption{test b}
\label{fig:example-image-b}
\end{figure}
\cite{knuth:ct,companion}
\printbibliography
\end{document}
得到结果:
和参考书目
如果你想更改 babel 常用的标题/名称,请查看这个答案。它显示了如何将巴西名称更改为\listfigurename
:
\addto\captionsbrazil{%
\renewcommand{\listfigurename}{Lista de ilustra\c{c}\~{o}es}%
}