## LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and Acronyms ⇒ Change 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

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!

1. \documentclass[fontsize=12pt,
2. paper=a4,
3. british,
4. ]{scrreprt}
5.
6. \usepackage{babel}
7. \usepackage[T1]{fontenc}
8. \usepackage{lmodern}
9. \usepackage{showframe}
10. \usepackage{nomentbl}
11. \makenomenclature
12.
13.
14. \begin{document}
15. \nomenclature[Ax]{$x$}{Coordinate}{m}%
16.
17. \printnomenclature
18.
19. \end{document}

1. actual '@'
2. quote '%'
3. delim_0 ""
4. delim_1 ""
5. delim_2 ""
6. item_0 ""
7. delim_t " \\\\\n"
8. line_max 1000
12. group_skip "\\\\*[\\parskip]"
13. preamble "\n\\begin{thenomenclature}\n%
14. \\begin{longtable}[l]%
15. {@{}lp{\\textwidth*\\real{0.5}}r!{\\extracolsep{\\fill}}lll}\n"
16. postamble "\n\\end{longtable}\n\n\\end{thenomenclature}\n"
17. keyword "\\nomenclatureentry"
18.
19. %%
20. %%
21. \endinput
Last edited by kongo on Wed Oct 23, 2019 9:12 am, edited 1 time in total.

Stefan Kottwitz
Posts: 9563
Joined: Mon Mar 10, 2008 9:44 pm
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

kongo
Posts: 5
Joined: Tue Oct 22, 2019 12:26 pm
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

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

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

nomenclature.png (52.33 KiB) Viewed 2002 times

The longtable is created with three additional columns:

1. {@{}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: 258
Joined: Sun Nov 16, 2014 8:51 pm
well, the first part about bold + sans is easy, just prepend \sffamily and \bfseries to \nomgroup, say

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.,
1. \documentclass[fontsize=12pt,
2. paper=a4,
3. british,
4. ]{scrreprt}
5.
6. \usepackage{babel}
7. \usepackage[T1]{fontenc}
8. \usepackage{lmodern}
9. \usepackage{showframe}
10. \usepackage{nomentbl}
11. \makenomenclature
12.
13. \makeatletter
14. \def\@@@nomenclature[#1]#2#3#4#5{%
15. \def\@tempa{#2}\def\@tempb{#3}%
16. \protected@write\@nomenclaturefile{}%
17. {\string\nomenclatureentry{#1\nom@verb\@tempa @{\nom@verb\@tempa}&%
18. \begingroup\nom@verb\@tempb\endgroup &\begingroup#4%%%\endgroup&%
19. |nompageref}{\thepage}%
20. }%
21. \endgroup
22. \@esphack
23. }
24. \makeatother
25.
26. \begin{document}
27. x
28. \nomenclature[Ax]{$x$}{Coordinate}{m}%
29.
30. \printnomenclature
31.
32. \end{document}

with
1. actual '@'
2. quote '%'
3. delim_0 ""
4. delim_1 ""
5. delim_2 ""
6. item_0 ""
7. delim_t " \\\\\n"
8. line_max 1000
12. group_skip "\\\\*[\\parskip]"
13. preamble "\n\\begin{thenomenclature}\n%
14. \\begin{longtable}[l]%
15. {@{}p{0.1\\textwidth}p{\\dimexpr0.8\\textwidth-4\\tabcolsep}>{\\raggedleft}p{0.1\\textwidth}@{}}\n"
16. postamble "\n\\end{longtable}\n\n\\end{thenomenclature}\n"
17. keyword "\\nomenclatureentry"
18.
19. %%
20. %%
21. \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
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: 258
Joined: Sun Nov 16, 2014 8:51 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 \\.
1. preamble "\n\\begin{thenomenclature}\n%
2. \\begin{longtable}[l]%
3. {@{}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
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?

1. {@{}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: 258
Joined: Sun Nov 16, 2014 8:51 pm
kongo wrote:Can you explain the meanings of the single modifications you made in the following line?

1. {@{}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
Hi Rainer,

I really appreciate your outstanding help! Thank you!

I modified my preamble in the following way:

1. \makeatletter
2. \def\@@@nomenclature[#1]#2#3#4#5{%
3. \def\@tempa{#2}\def\@tempb{#3}%
4. \protected@write\@nomenclaturefile{}%
5. {\string\nomenclatureentry{#1\nom@verb\@tempa @{\nom@verb\@tempa}&%
6. \begingroup\nom@verb\@tempb\endgroup &\begingroup#4%%%\endgroup&%
7. |nompageref}{\thepage}%
8. }%
9. \endgroup
10. \@esphack
11. }
12. \renewcommand\nomgroup[1]{%
13. \ifthenelse{\equal{#1}{A}}{%
14. {\nomAname}}{%
15. \ifthenelse{\equal{#1}{G}}{%
16. {\nomGname}}{%
17. \ifthenelse{\equal{#1}{X}}{%
18. {\nomXname}}{%
19. \ifthenelse{\equal{#1}{Z}}{%
20. {\nomZname}}{%
21. {}}}}}}
22. \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: 258
Joined: Sun Nov 16, 2014 8:51 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

KR
Rainer