带框的命名法和与 pardent 的对齐

带框的命名法和与 pardent 的对齐

我想使用 nomencl 包生成命名法,该命名法应位于一个框架中,并且标题和符号列都与全局 parindent 值对齐。文档类必须是 elsarticle,结果应该由此类给出的值控制 - 因此如果有意义的话,我无法更改全局值。

无论如何,到目前为止,我发现可以使用 patchcmd 来实现符号列的对齐。不幸的是,我不知道如何对标题做同样的事情,也试图弄乱给出的帮助这里,但没有成功。

我附加了一个示例,其中的缩进和 fbox 分隔和标尺值都非常夸张,以使问题更加严重。

其中我尝试过手动用 hspace 命令移动 header,但效果并不好,如图所示。还是有间隙,这很大程度上取决于设置的 parindent 和 frame box 设置。

我期待您的建议。

亲切的问候

塞巴斯蒂安命名法标题与 parindent 不一致

% arara: pdflatex
% arara: nomencl
% arara: pdflatex
\documentclass[preprint,3p, times]{elsarticle}
\usepackage[fontsize=8.0pt]{fontsize}
\usepackage{amssymb}
\usepackage{showframe}
\usepackage{lipsum}


% these are relevant variables to play around in order to check dependencies
% parident, nomenclature header and nomenclature symbol column should always
% start at the same horizontal position, no matter hwo the parameter change.
   \setlength{\parindent}{5.25em}
   \setlength{\fboxsep}{1.35em}
   \setlength{\fboxrule}{0.55em}


% BEGIN PACKAGE
% package to define a nomenclature
   \usepackage{nomencl}
   % OPTION: no empty line between nomenclature lines
   \setlength{\nomitemsep}{-\parsep}
   % OPTION: manipulate distance between symbol column and explanation column
   \setlength{\nomlabelwidth}{2.5cm}
   % MODIFICATION: new command to make a box around nomenclature
   % definition of space between top box line and start of Nomenclature
   \newlength{\nomclVspaceTop}
   \setlength{\nomclVspaceTop}{-1.75\baselineskip}
   % definition of space between end of Nomenclature and bottom box line
   \newlength{\nomclVspaceBot}
   \setlength{\nomclVspaceBot}{-0.25\baselineskip}
   % definition of the framed box
   % parbox inside a fbox
   \newcommand*\widefbox[1]{\fbox{\parbox{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}{
                     \vspace{\nomclVspaceTop}\hspace{1ex}#1\vspace{\nomclVspaceBot}}}}

   % Nomenclature environment sets a local \parindent with 0.0, we need to shift environment by
   % global parident
   \newlength{\globalParindent}
   \setlength{\globalParindent}{\dimexpr \the\parindent \relax}

   % xpatch package allows to change lines of a package temporary
   % here: the left symbol colum is indented accordinglig
   \usepackage{xpatch}
   \patchcmd{\thenomenclature}
      % search for original line of source code
      {\leftmargin\labelwidth}
      % replace with
      {\leftmargin\labelwidth\itemindent \dimexpr \globalParindent-\fboxsep -\fboxrule \relax  }
      % in case of success
      {\typeout{Success}}
      % in case it fails
      {\typeout{Failure}}

   % definition of the complete nomenclature
   \newcommand{\printNomenclatureWithBox}{\noindent\widefbox{
   \printnomenclature}}
   \makenomenclature
% END PACKAGE

\begin{document}
% Nomenclatur content
\nomenclature{$m$}{Mass of a point object}
\nomenclature{$v$}{Speed of a point object}
\nomenclature{$E_{kin}$}{Kinetic Energy of a point object}

\indent Nomenclature: here should it actually start \\
\printNomenclatureWithBox \\
\indent Nomenclature: here should it actually start


% FIXME: indent the section title by redefine name of nomenclature
%        result not satisfying
\renewcommand{\nomname}{\hspace{\dimexpr \globalParindent -\fboxsep  -\fboxrule  \relax}
Nomenclature - parident var: local = \the\parindent, global = \the\globalParindent }

\printNomenclatureWithBox \\
\indent Nomencalture: here should it actually start. \lipsum[1-3]
\end{document}

相关内容