![由于 `glossaries-extra` 导致水平盒子过满](https://linux22.com/image/427777/%E7%94%B1%E4%BA%8E%20%60glossaries-extra%60%20%E5%AF%BC%E8%87%B4%E6%B0%B4%E5%B9%B3%E7%9B%92%E5%AD%90%E8%BF%87%E6%BB%A1.png)
根据我的另一个问题确定这里. 警告如下
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}