集中词汇表的组标题

集中词汇表的组标题

我一直用glossaries-extra它来生成论文中的符号列表,但格式方面却让我很头疼。更具体地说,问题是我的章节标题居中,但词汇表组标题却不是。

我已经看过画廊了自定义组块以及不同的格式style,但我还没有找到解决办法。理想情况下,列表应该看起来像style=long(见下图),但有居中的组标题。

是否有一种简单的方法可以将词汇表的组标题居中?

梅威瑟:

\documentclass[parskip,12pt,oneside,a4paper]{scrbook}
\usepackage[record,symbols,nomain,stylemods={tree},shortcuts=other]{glossaries-extra}

\renewcommand*{\raggedchapter}{\centering}% Make chapters centred
\addtokomafont{disposition}{\rmfamily}% Roman fonts for Ch

\glsxtrsetgrouptitle{bte}{Neutron transport}
\glsxtrsetgrouptitle{angdisc}{Angular discretisations}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{r}{
  name={\ensuremath{\mathbf{r}}},
  description={Position},
  group={bte},
  type={symbols}
}
\newentry{S2}{
  name={\ensuremath{\mathit{S_2}}},
  description={Angular domain: the unit sphere},
  group={bte},
  type={symbols}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{SN}{
  name={\ensuremath{S_N}},
  description={Discrete Ordinates discretisation of \gls{S2}},
  group={angdisc},
  type={symbols}
}
\newentry{PN}{
  name={\ensuremath{P_N}},
  description={Spherical Harmonics discretisation of \gls{S2}},
  group={angdisc},
  type={symbols}
}

% \printunsrtglossary[type=symbols,style=long,title={List of Symbols}]
\printunsrtglossary[type=symbols,style=indexgroup,title={List of Symbols}]
\clearpage

\end{document}

答案1

要回答这个问题,你可以简单地通过使用更新格式

\renewcommand\glstreegroupheaderfmt[1]{\begin{center}\textbf{#1}\end{center}\vspace{-\parskip}}

并切换到alttreegroup样式。因此你还必须使用

\glsfindwidesttoplevelname

在调用之前\printunsrtglossary。最后它应该看起来像这样:

在此处输入图片描述

答案2

测试了几个替代方案,包括@Venez 发布的答案,我认为这个问题最简单的解决方案是根据 定义一个新的词汇表样式long。该long样式实际上是一个longtable,这意味着简单的列操作可以产生所需的样式,即居中的组标题和词汇表条目被放置在页面的中心。

解决方案:

\documentclass[parskip,12pt,oneside,a4paper]{scrbook}
\usepackage[record,symbols,nomain,stylemods={tree},shortcuts=other]{glossaries-extra}% list of symbols

\renewcommand*{\raggedchapter}{\centering}% Make chapters centred
\addtokomafont{disposition}{\rmfamily}% Roman fonts for Ch

\glsxtrsetgrouptitle{bte}{Neutron transport}
\glsxtrsetgrouptitle{angdisc}{Angular discretisations}

% Define a custom long style for groups; style=long uses longtables
\newglossarystyle{longgroup}{%
    \setglossarystyle{long}%
  \renewcommand*{\glsgroupheading}[1]{%
    &%  Add empty column in longtable 
    \multicolumn{1}{c}{% Change the alignment just for the group title to centre
          \glsxtrgetgrouptitle{##1}{\glsxtrgrptitle}%
          % \glstreePreHeader{##1}{\glsxtrgrptitle}%
      \glstreegroupheaderfmt{\glsxtrgrptitle}%
    }%
    \cr% newline in table
    %\glsgroupskip% Uncomment for additional spacing below group title
    }%
}%

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{r}{
  name={\ensuremath{\mathbf{r}}},
  description={Position},
  group={bte},
  type={symbols}
}
\newentry{S2}{
  name={\ensuremath{\mathit{S_2}}},
  description={Angular domain: the unit sphere},
  group={bte},
  type={symbols}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{SN}{
  name={\ensuremath{S_N}},
  description={Discrete Ordinates discretisation of \gls{S2}},
  group={angdisc},
  type={symbols}
}
\newentry{PN}{
  name={\ensuremath{P_N}},
  description={Spherical Harmonics discretisation of \gls{S2}},
  group={angdisc},
  type={symbols}
}

% \printunsrtglossary[type=symbols,style=long,title={List of Symbols}]
\printunsrtglossary[type=symbols,style=longgroup,title={List of Symbols}]
\clearpage

\end{document}

在此处输入图片描述

相关内容