对于以下 MWE
% arara: lualatex: { options: [ '-synctex=1', '-shell-escape' ]}
% arara: makeglossaries
% arara: lualatex: { options: [ '-synctex=1', '-shell-escape' ]}
\documentclass{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{calc,siunitx,booktabs,lipsum}
\sisetup{load-configurations = abbreviations}
\usepackage[automake,stylemods,symbols,
xindy={codepage=utf8, language=greek, glsnumbers=false}
]{glossaries-extra}
\makeglossaries
\newlength\glsnamewidth
\newlength\glsunitwidth
\settowidth{\glsnamewidth}{\textbf{sign}}
\settowidth{\glsunitwidth}{\textbf{unit}}
\newglossarystyle{nameunitdesc}{%
\setlength{\glsdescwidth}{\linewidth-\glsnamewidth-\glsunitwidth-4\tabcolsep}%
\renewenvironment{theglossary}%
{\begin{supertabular}{@{}p{\glsnamewidth}p{\glsunitwidth}p{\glsdescwidth}@{}}\toprule\addlinespace[5pt]}%
{\bottomrule\end{supertabular}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand{\glossentry}[2]{%
\raggedright\glstarget{##1}{\glossentryname{##1}} &
\centering\glossentrysymbol{##1} &
\glossentrydesc{##1}\tabularnewline
}%
\renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
\renewcommand*{\glsgroupskip}{}%
}
\glsnoexpandfields
\newglossaryentry{Cp}{name={Cp},description={specific heat}, symbol={[\si{\J\per\kg\per\K}]}}
\journal{Journal name}
\begin{document}
\begin{frontmatter}
\title{Title}
\begin{abstract}
\lipsum[1]
\end{abstract}
\end{frontmatter}
\gls{Cp}
\glsFindWidestUsedAnyNameSymbol{\glsunitwidth}
\settowidth{\dimen0}{\glsgetwidestname}
\ifdim\dimen0>\glsnamewidth
\glsnamewidth=\dimen0
\fi
\printglossary[style=nameunitdesc,title=Nomenclature]
\end{document}
在这一行中\setlength{\glsdescwidth}{\linewidth-\glsnamewidth-\glsunitwidth-2\tabcolsep}
,直观地讲,我需要减去2\tabcolsep
以使描述字段跨越整个行宽,但是,减去4\tabcolsep
会导致词汇表的右边距正确对齐:
减去2\tabcolsep
会导致词汇表右边距溢出以下情况:
\tabcolsep
那么,如何不经过反复试验就能准确计算出需要减去的数量呢?