由于 `glossaries-extra` 导致水平盒子过满

由于 `glossaries-extra` 导致水平盒子过满

根据我的另一个问题确定这里. 警告如下

46-46 行对齐时 \hbox 过满(宽了 28.00505pt)

似乎是在使用该glossaries-extra包时产生的。

这是一个 MWE,它输出了我提到的 3 倍的警告。

看起来test.tex

%!TEX root = test.tex
%!TEX program = latexmk
%!TEX encoding = UTF-8 Unicode
%!TEX spellcheck = en-US

\RequirePackage[l2tabu,orthodox]{nag}
% \RequirePackage{luatex85}
% \documentclass[a4paper,11pt,abstract=true]{scrreprt} % this is the main file
\documentclass[a4paper,11pt]{scrbook}
% \usepackage{refcheck}
% \usepackage{showkeys}
% for info on KOMA script see
% http://www.golatex.de/wiki/KOMA-Script
% fix incompatibilities of some packages with KOMA script
\usepackage[automark,headsepline=.5pt]{scrlayer-scrpage}
\usepackage{siunitx} % add SI unit convention support

\usepackage[record,% using bib2gls
    symbols, % create list of symbols
    stylemods={longextra}, % load glossary-longextra.sty
    nogroupskip
]{glossaries-extra}

\GlsXtrLoadResources[
    src={symbols}, % data in symbols.bib
    sort-field={name}, % sort by name field
    sort={letter-nocase}, % case-insensitive letter sort
    type=symbols, % put these terms in the symbols list
    field-aliases={unit=symbol},% convert unit key to symbol
    save-locations=false, % don't save location lists
    selection={all}, % print all without using
]

\begin{document}

\renewcommand{\symbolname}{Unit}
\renewcommand{\glslongextraNameAlign}{c}
\renewcommand{\glslongextraSymbolAlign}{r}
\printunsrtglossary[type=symbols,style=long-name-desc-sym]


\end{document}

并且symbols.bib

% Encoding: UTF-8

% requires siunitx.sty

@symbol{cP,
  unit = {\si{\square\metre\per\square\second\per\kelvin}},
  name = {\ensuremath{c_P}},
  description = {Specific heat at constant pressure}
}

答案1

问题是由于条目的宽度,用于表的长表太宽。

固定宽度描述列的样式由

\newcommand{\glslongextraDescAlign}{>{\raggedright}p{\glsdescwidth}}

因此,正确的解决方案很可能是将其设置\glsdescwidth为少 30pt,但我看不到它设置在哪里(我不知道这个包),而仅在序言中将其减少 30pt 并没有效果,所以我改用

\renewcommand{\glslongextraDescAlign}{>{\raggedright}p{\dimexpr\glsdescwidth-30pt}}

因此 longtable 使用的中间列比以前少了 30pt,然后表格就适合页面了。

\documentclass[a4paper,11pt]{scrbook}
% \usepackage{refcheck}
% \usepackage{showkeys}
% for info on KOMA script see
% http://www.golatex.de/wiki/KOMA-Script
% fix incompatibilities of some packages with KOMA script
\usepackage[automark,headsepline=.5pt]{scrlayer-scrpage}
\usepackage{siunitx} % add SI unit convention support

\usepackage[record,% using bib2gls
    symbols, % create list of symbols
    stylemods={longextra}, % load glossary-longextra.sty
    nogroupskip
]{glossaries-extra}

\GlsXtrLoadResources[
    src={symbols}, % data in symbols.bib
    sort-field={name}, % sort by name field
    sort={letter-nocase}, % case-insensitive letter sort
    type=symbols, % put these terms in the symbols list
    field-aliases={unit=symbol},% convert unit key to symbol
    save-locations=false, % don't save location lists
    selection={all}, % print all without using
]

\begin{document}

\renewcommand{\symbolname}{Unit}
\renewcommand{\glslongextraNameAlign}{c}
\renewcommand{\glslongextraSymbolAlign}{r}
%
\renewcommand{\glslongextraDescAlign}{>{\raggedright}p{\dimexpr\glsdescwidth-30pt}}
\printunsrtglossary[type=symbols,style=long-name-desc-sym]


\end{document}

相关内容