我希望可以将各个组放在nomenclature
不同的页面中,并将其标题居中。到目前为止,我尝试了以下 MWE:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{nomencl}
\makenomenclature
\renewcommand\nomgroup[1]{%
\item[\centering\normalsize\bfseries
\ifstrequal{#1}{A}{%
\MakeUppercase{List of Abbreviations and Acronyms}%
}{%
\ifstrequal{#1}{S}{\MakeUppercase{List of Symbols}}{}}%
]\thispagestyle{empty}}
\renewcommand{\nomname}{}
\begin{document}
\nomenclature[A]{H2O}{Water}
\nomenclature[A]{CO2}{Chemical 1}
\nomenclature[A]{CO}{Chemical 2}
\nomenclature[A]{HC}{Chemical 3}
\nomenclature[A]{kWp}{kilowatt-peak}
\nomenclature[S]{EPE}{Research Electrical Company}
\printnomenclature[1cm]
\end{document}
我懂了:
但我希望将它们放在不同的页面中,并将标题居中,如下所示:
解决方案这里似乎解决了页面不同问题,但无法解决标题居中问题。有人能帮我吗?
答案1
这里的问题是,命令\nomgroup
需要是才能\item
打印在命名法中。因此,您尝试使用\centering
(即内部)\item[]
无法工作。
一种解决方法是使用下面的代码(参见\hfill
在标签定义之外使用\item
;用 标记的重要代码<======
):
\item[]% <=============================================================
{\hfil\normalsize\bfseries % <======================================
\ifstrequal{#1}{A}{%
\MakeUppercase{List of Abbreviations and Acronyms}%
}{%
\ifstrequal{#1}{S}{\MakeUppercase{List of Symbols}}{}%
}%
\hfil} % <==========================================================
请注意,这种居中并不是非常完美,因为没有包括标签的长度......这就是我称之为解决方法的原因......
完整代码如下
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{showframe}% <============ to visualize text area and margins
\usepackage{nomencl}
\makenomenclature
\newif\iffirstglossary\firstglossarytrue
\renewcommand\nomgroup[1]{%
\iffirstglossary
\firstglossaryfalse
\else
\clearpage
\fi
\item[]% <=============================================================
{\hfil\normalsize\bfseries % <======================================
\ifstrequal{#1}{A}{%
\MakeUppercase{List of Abbreviations and Acronyms}%
}{%
\ifstrequal{#1}{S}{\MakeUppercase{List of Symbols}}{}%
}%
\hfil} % <==========================================================
%] % <==================================================================
\thispagestyle{empty}}
\renewcommand{\nomname}{}
\begin{document}
\nomenclature[A]{H2O}{Water}
\nomenclature[A]{CO2}{Chemical 1}
\nomenclature[A]{CO}{Chemical 2}
\nomenclature[A]{HC}{Chemical 3}
\nomenclature[A]{kWp}{kilowatt-peak}
\nomenclature[S]{EPE}{Research Electrical Company}
\printnomenclature[1cm]
\end{document}
您将获得以下结果: