LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and AcronymsChange format of nomenclature

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
kongo
Posts: 5
Joined: Tue Oct 22, 2019 12:26 pm

Change format of nomenclature

Postby kongo » Tue Oct 22, 2019 12:36 pm

Hi there,

I am using the nomentbl package to create a nomenclature. I have to meet several design requirements and therefore, I have to modify the style of nomentbl. Unfortunately, I do not know how this can be done:

There is an empty space between the right limit of \textwidth and the unit-column. How can I remove this? The units should flush right. Furthermore, I want the headings (e.g. "Latin Letters") to appear in bold and sans serif font.

How should I modify the code to achieve this goals?

Thank you very much!

\documentclass[fontsize=12pt,
               paper=a4,
               british,
              ]{scrreprt}

\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{showframe}
\usepackage{nomentbl}
\makenomenclature


\begin{document} 
\nomenclature[Ax]{$x$}{Coordinate}{m}%

\printnomenclature

\end{document}


actual '@'
quote '%'
delim_0   ""
delim_1   ""
delim_2   ""
item_0    ""
delim_t   " \\\\\n"
line_max  1000
heading_prefix   "\\multicolumn{3}{@{}l}{\\nomgroup{"
heading_suffix   "}} \\\\\n\\nopagebreak\\\\*[\\parskip]\n\\nopagebreak{}"
headings_flag       1
group_skip        "\\\\*[\\parskip]"
preamble "\n\\begin{thenomenclature}\n%
\\begin{longtable}[l]%
{@{}lp{\\textwidth*\\real{0.5}}r!{\\extracolsep{\\fill}}lll}\n"
postamble "\n\\end{longtable}\n\n\\end{thenomenclature}\n"
keyword "\\nomenclatureentry"

%%
%%
\endinput
Last edited by kongo on Wed Oct 23, 2019 9:12 am, edited 1 time in total.

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10068
Joined: Mon Mar 10, 2008 9:44 pm

Change format of nomenclature

Postby Stefan Kottwitz » Wed Oct 23, 2019 12:17 am

Hi kongo,

welcome to the forum!

Do you have further instructions how to reproduce the problem? There was no answer yet, perhaps people like me were not able to process the file with makeindex and nomenclature settings.

You may also attach the log files, standard .log and nomencl log.

Stefan
LaTeX.org admin

kongo
Posts: 5
Joined: Tue Oct 22, 2019 12:26 pm

Change format of nomenclature

Postby kongo » Wed Oct 23, 2019 9:30 am

Hi Stefan,

I reviewed my code and indeed, there was an error (wrong brace). Now the code (start post) should run.

To be clear, I use the nomentbl package to create the nomenclature. So you have to run makeindex with

makeindex -s modified-nomentbl.ist -o filename.nls filename.nlo


Please see the attached picture which shows what I want to achieve.

nomenclature.png
nomenclature.png (52.33 KiB) Viewed 11530 times


The longtable is created with three additional columns:

{@{}lp{\\textwidth*\\real{0.5}}r!{\\extracolsep{\\fill}}lll}\n"


Deleting them doesn't work, so I need a way to remove the white space between the "unit"-column and the right border.

Thank you!

rais
Posts: 394
Joined: Sun Nov 16, 2014 8:51 pm

Change format of nomenclature

Postby rais » Wed Oct 23, 2019 11:07 pm

well, the first part about bold + sans is easy, just prepend \sffamily and \bfseries to \nomgroup, say
heading_prefix   "\\multicolumn{3}{@{}l}{\\sffamily\\bfseries\\nomgroup{"

the second part about the unit right aligned needs a bit more tinkering...
(come to think of it, you may be better of with another package, e. g., glossaries, where not as much `tinkering' would be needed)

First, you need to tell \nomenclature (actually, the `inner' command, \@@@nomenclature) to use three columns. Then you can omit the trailing lll column specifiers and modify the others until your specs are achieved, e.g.,
\documentclass[fontsize=12pt,
               paper=a4,
               british,
              ]{scrreprt}
 
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{showframe}
\usepackage{nomentbl}
\makenomenclature

\makeatletter
  \def\@@@nomenclature[#1]#2#3#4#5{%
    \def\@tempa{#2}\def\@tempb{#3}%
    \protected@write\@nomenclaturefile{}%
    {\string\nomenclatureentry{#1\nom@verb\@tempa @{\nom@verb\@tempa}&%
      \begingroup\nom@verb\@tempb\endgroup &\begingroup#4%%%\endgroup&%
      |nompageref}{\thepage}%
    }%
    \endgroup
    \@esphack
  }
\makeatother
 
\begin{document}
x
\nomenclature[Ax]{$x$}{Coordinate}{m}%
 
\printnomenclature
 
\end{document}

with
actual '@'
quote '%'
delim_0   ""
delim_1   ""
delim_2   ""
item_0    ""
delim_t   " \\\\\n"
line_max  1000
heading_prefix   "\\multicolumn{3}{@{}l}{\\sffamily\\bfseries\\nomgroup{"
heading_suffix   "}} \\\\\n\\nopagebreak\\\\*[\\parskip]\n\\nopagebreak{}"
headings_flag       1
group_skip        "\\\\*[\\parskip]"
preamble "\n\\begin{thenomenclature}\n%
\\begin{longtable}[l]%
{@{}p{0.1\\textwidth}p{\\dimexpr0.8\\textwidth-4\\tabcolsep}>{\\raggedleft}p{0.1\\textwidth}@{}}\n"
postamble "\n\\end{longtable}\n\n\\end{thenomenclature}\n"
keyword "\\nomenclatureentry"
     
%%
%%
\endinput

BTW: the code in your OP didn't work.
The superfluous closing brace you found yourself, great.
The thing with nomencl/nomentbl is, if there's no text, no nomenclature is produced.
Since your OP doesn't contain any text, its output is empty.

Please note that this code breaks some of nomencl's features.

KR
Rainer

kongo
Posts: 5
Joined: Tue Oct 22, 2019 12:26 pm

Change format of nomenclature

Postby kongo » Thu Oct 24, 2019 2:59 pm

Hi Rainer,

Thank you, but unfortunately, this doesn't work, if there are more than one nomenclature entries.

Which features will this break?

rais
Posts: 394
Joined: Sun Nov 16, 2014 8:51 pm

Change format of nomenclature

Postby rais » Thu Oct 24, 2019 8:14 pm

kongo wrote:this doesn't work, if there are more than one nomenclature entries.

oops, my bad... \raggedleft and friends change the meaning of \\.
preamble "\n\\begin{thenomenclature}\n%
\\begin{longtable}[l]%
{@{}p{0.1\\textwidth}p{\\dimexpr0.8\\textwidth-4\\tabcolsep}>{\\raggedleft\\arraybackslash}p{0.1\\textwidth}@{}}\n"
should fix that in your .ist file.
kongo wrote:Which features will this break?

Ever wondered why there were so many columns defined?
`refeq' is one of those features (because its result would be ignored by the change in \@@@nomenclature).
`refpage' might even still work, but it'd shift your units to the left (to make room for the page numbers).

KR
Rainer

kongo
Posts: 5
Joined: Tue Oct 22, 2019 12:26 pm

Change format of nomenclature

Postby kongo » Sat Oct 26, 2019 12:37 pm

Thank you! I had to tweak the \textwidth portions but now it runs perfect!

Can you explain the meanings of the single modifications you made in the following line?

{@{}p{0.1\\textwidth}p{\\dimexpr0.8\\textwidth-4\\tabcolsep}>{\\raggedleft\\arraybackslash}p{0.1\\textwidth}@{}}


So I can understand what's going on :)

EDIT: I need an additional modification: The size of "Latin Letters" should be set to \normalsize, but this doesn't work...

Thanks!

rais
Posts: 394
Joined: Sun Nov 16, 2014 8:51 pm

Change format of nomenclature

Postby rais » Sat Oct 26, 2019 1:59 pm

kongo wrote:Can you explain the meanings of the single modifications you made in the following line?

{@{}p{0.1\\textwidth}p{\\dimexpr0.8\\textwidth-4\\tabcolsep}>{\\raggedleft\\arraybackslash}p{0.1\\textwidth}@{}}


I can try :)
the first @{} suppresses the space normally reserved to the left of the first column. Similarily, the last @{} suppresses the space normally reserved to the right of the last column.
p{0.1\textwidth}declares a column a tenth of the text width wide (1st and 3rd columns).
p{\dimexpr0.8\textwidth-4\tabcolsep}
calculates as "text width minus the width of the other (two) columns (0.8\textwidth), minus ( n * 2 - 2 ) reserved space left and right of each column" (with n as number of columns; two less because of the two suppressions of the leftmost/rightmost spaces. So n = 3, 3*2-2 results in 4, and the length for the reserved space for each column left/right is \tabcolsep).
>{\raggedleft\arraybackslash} modifies the last column to align cell contents flush to the right---and the \arraybackslash redefines \\ to \tabularnewline so \\ can be used again to end a tabular line, like without the \raggedleft.
Come to think of it, the last column spec might have been w{r}{0.1\textwidth}, as well.

For further information you may wish to consult the array documentation.
kongo wrote:EDIT: I need an additional modification: The size of "Latin Letters" should be set to \normalsize, but this doesn't work...

then you have to copy nomentbl's definition of \nomgroup into your preamble and omit all \large commands from it.

KR
Rainer

kongo
Posts: 5
Joined: Tue Oct 22, 2019 12:26 pm

Change format of nomenclature

Postby kongo » Sat Oct 26, 2019 3:12 pm

Hi Rainer,

I really appreciate your outstanding help! Thank you!

I modified my preamble in the following way:

\makeatletter
  \def\@@@nomenclature[#1]#2#3#4#5{%
    \def\@tempa{#2}\def\@tempb{#3}%
    \protected@write\@nomenclaturefile{}%
    {\string\nomenclatureentry{#1\nom@verb\@tempa @{\nom@verb\@tempa}&%
      \begingroup\nom@verb\@tempb\endgroup &\begingroup#4%%%\endgroup&%
      |nompageref}{\thepage}%
    }%
    \endgroup
    \@esphack
  }
  \renewcommand\nomgroup[1]{%
    \ifthenelse{\equal{#1}{A}}{%
      {\nomAname}}{%
      \ifthenelse{\equal{#1}{G}}{%
        {\nomGname}}{%
        \ifthenelse{\equal{#1}{X}}{%
          {\nomXname}}{%
          \ifthenelse{\equal{#1}{Z}}{%
	  {\nomZname}}{%
          {}}}}}}
\makeatother


This seems to work. I just want to confirm that this is what you meant. I would like to avoid that I have done something wrong and run into problems sometime later.

rais
Posts: 394
Joined: Sun Nov 16, 2014 8:51 pm

Change format of nomenclature

Postby rais » Sat Oct 26, 2019 4:27 pm

You're welcome and yes, that is what I meant.
It doesn't need to be within \makeatletter/\makeatother, though (there's no @ in any of the command names used in \nomgroup's definition).
kongo wrote:I would like to avoid that I have done something wrong and run into problems sometime later.

Don't you worry, problems tend to present themselves anyway :D

KR
Rainer


Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 1 guest