我使用 nomencl 创建论文的命名法。
论文由三章组成,我更喜欢为每一章单独列出一个列表。
我目前使用最小工作示例中的代码实现了这一点。
不幸的是,章节名称很长。因此它们不适合一行。
我怎样才能让章节名称继续在下一行?
我怎样才能使它对齐,使得第二行不是从头开始(“章节...”下方)而是在破折号后的章节名称下方(“相当长的标题...”)。
\documentclass[a4paper,12pt]{book}
\usepackage[british,ngerman]{babel}
\usepackage{longtable} % longtable lets you have tables that span multiple pages
\usepackage{nomencl}
\makenomenclature
\renewcommand{\nomname}{List of Symbols}
\renewcommand{\nompreamble}{just some symbols}
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
\item[\bfseries
\ifstrequal{#1}{A}{Common}{%
\ifstrequal{#1}{B}{Chapter 2 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}{%
\ifstrequal{#1}{C}{Chapter 3 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}{}}}%
]}
\begin{document}
\tableofcontents
\nomenclature[A, 1]{$\gamma$}{text}
\nomenclature[A, 2]{$B$}{text}
\nomenclature[B, 1]{$\beta$}{text}
\nomenclature[B, 2]{$S$}{text}
\nomenclature[C, 1]{$\alpha$}{text}
\nomenclature[C, 2]{$\beta$}{text}
\printnomenclature[2cm]
\end{document}enter code here
答案1
我能够用“parbox”解决这个问题:
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
\item[\bfseries
\ifstrequal{#1}{A}{Common}{%
\ifstrequal{#1}{B}{{\parbox[t]{16cm}{Chapter 2 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}}}{%
\ifstrequal{#1}{C}{{\parbox[t]{16cm}{Chapter 3 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}}}{}}}%
]}
答案2
你的想法\parbox
很好,但我建议做几点改进,首先避免猜测宽度。
\documentclass[a4paper,12pt]{book}
\usepackage[british,ngerman]{babel}
\usepackage{nomencl}
\usepackage{xparse}
\makenomenclature
\renewcommand{\nomname}{List of Symbols}
\renewcommand{\nompreamble}{just some symbols}
\newcommand{\nomA}{Common}
\newcommand{\nomB}{%
\parbox[t]{\textwidth}{%
Chapter 2 - A quite long title, a quite long title, a quite long title,
a quite long title, a quite long title%
}\kern-\labelsep
}
\newcommand{\nomC}{%
\parbox[t]{\textwidth}{%
Chapter 3 - A quite long title, a quite long title, a quite long title,
a quite long title, a quite long title%
}\kern-\labelsep
}
% this is easier than a long list of nested \ifstrequal calls and more easily scalable
\ExplSyntaxOn
\NewDocumentCommand{\nomgroupmake}{m}
{
\str_case:nnF { #1 }
{
{A}{\nomA}
{B}{\nomB}
{C}{\nomC}
}
{\ERROR}
}
\ExplSyntaxOff
\renewcommand\nomgroup[1]{\item[\bfseries\nomgroupmake{#1}]}
\begin{document}
Some text to make the nomenclature appear
\nomenclature[A,1]{$\gamma$}{text}
\nomenclature[A,2]{$B$}{text}
\nomenclature[B,1]{$\beta$}{text}
\nomenclature[B,2]{$S$}{text}
\nomenclature[C,1]{$\alpha$}{text}
\nomenclature[C,2]{$\beta$}{text}
\printnomenclature[2cm]
\end{document}