1

I want to generate a nomenclature with the nomencl package, which should be in a framed box and where both the header and symbol column are aligned with the global parindent value. The document class must be elsarticle and the result should be kind of steered by the values given by this class - so I'm not able to change global values if that makes sense.

Anyways, so far I found out that the alignment of the symbol column can be achieved by using the patchcmd. Unfortunately, I couldn't figure out how to do the same with the header, also tried to mess around with the help given here, but without success.

I've attached an example with highly exaggerated indentation and fbox' separation and ruler values to make the problem more drastic.

Therein, I've tried to shift the header manually by an hspace command, but the result is not good as shown in the picture. There is still a gap which is highly dependent on the set parindent and frame box settings.

I'm looking forward to your suggestions.

Kind regards

SebastianNomenclature header not aligned with 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}
2
  • Welcome to TeX.SE!
    – Mensch
    Commented Apr 5 at 10:57
  • @Mensch Thank you! Commented Apr 5 at 12:27

0

You must log in to answer this question.

Browse other questions tagged .