nomgroup の nomencl で改行

nomgroup の nomencl で改行

私は論文の命名法を作成するために nomencl を使用しています。
論文は 3 つの章で構成されており、それぞれの章に個別のリストを用意したいと考えています。
現在、最小限の動作例のコードを使用してこれを実現しています。
残念ながら、章の名前は非常に長いです。そのため、1 行に収まりません。

章の名前を次の行に続けるに
はどうすればよいですか。2 行目が先頭 (「章...」の下) から始まるのではなく、ダッシュの後の章の名前の下 (「非常に長いタイトル...」) から始まるように配置するにはどうすればよいですか。

\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}

ここに画像の説明を入力してください

関連情報