我有一份使用scrreprt
包含命名法的类的文档。命名法使用带标题的子组。我想将标题格式化为文档的章节标题,即字体系列和大小应该相同。理想情况下,子组、子组标题和下一个子组之间的垂直间距也与段落、章节标题和下一个段落之间的垂直间距相同。
这个 MWE 展示了我迄今为止所取得的成就
\documentclass{scrreprt}
\usepackage{nomencl}
\usepackage{ifthen}
% No extra line space between items
\setlength{\nomitemsep}{-\parsep}
% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{\baselineskip}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2ex}
\newcommand\groupHeading[1]{%
\vspace{\preGroupSkip}%
\item[\hspace*{\usekomafont{sectioning}\usekomafont{section} #1]%
\hspace*{-\leftmargin}\vspace{\postGroupSkip}
}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{A}}{%
\groupHeading{Heading of group A}%
}{}%
\ifthenelse{\equal{#1}{B}}{%
\groupHeading{Heading of group B}%
}{}%
\ifthenelse{\equal{#1}{C}}{%
\groupHeading{Heading of group C}%
}{}%
}
\makenomenclature
\begin{document}
% Define nomenclature entries
\nomenclature[a]{$\alpha$}{Some angle}
\nomenclature[b]{$b$}{Some variable}
\nomenclature[c]{$\mathbf c$}{Some vector}
\printnomenclature{}
dummy text
\end{document}
这是结果(绿线是我画的):
除了子组标题的对齐方式(当然,子组标题应与绿线对齐)之外,它接近我想要实现的效果。如果我只使用正常格式,没有\usekomafont{}
,则不会发生错位。所以这一定与此有关。只是我搞不清楚这是什么关系。如何正确对齐子组标题?
此外,我应该如何选择\preGroupSkip
和\postGroupSkip
,以便它们分别对应于段落与其标题之间以及段落与下一段落标题之间的垂直空间?
答案1
\usekomafont{section}
删除和之间的空格#1
:
\item[\usekomafont{sectioning}\usekomafont{section}#1]%
代码:
\documentclass{scrreprt}
\usepackage{nomencl}
\usepackage{ifthen}
% No extra line space between items
\setlength{\nomitemsep}{-\parsep}
% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{3.5ex}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2.3ex}
\newcommand\groupHeading[1]{%
\par\vspace{\preGroupSkip}%
\item[\usekomafont{sectioning}\usekomafont{section}#1]%
\hspace*{-\leftmargin}\vspace{\postGroupSkip}%
}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{A}}{%
\groupHeading{Heading of group A}%
}{}%
\ifthenelse{\equal{#1}{B}}{%
\groupHeading{Heading of group B}%
}{}%
\ifthenelse{\equal{#1}{C}}{%
\groupHeading{Heading of group C}%
}{}%
}
\makenomenclature
\begin{document}
% Define nomenclature entries
\nomenclature[a]{$\alpha$}{Some angle}
\nomenclature[b]{$b$}{Some variable}
\nomenclature[c]{$\mathbf c$}{Some vector}
\printnomenclature{}
dummy text
\end{document}