Ordered symbols list with units
I would like to create a symbols list using makeglossaries, but, it has to be ordered and the symbols must have their respective units too.
On the quest for a solution to my issue I came across two answers that contain what I want but both only have one of the desired outcomes.
1st- Symbols with units but no sorting (ode taken from glossaries: How to customize list of symbols with additional column for units?
documentclass{book}
usepackage{siunitx}
usepackage[symbols,nogroupskip,nonumberlist,automake]{glossaries-extra} % use glossaries-package
usepackage{subfiles}
setlength{glsdescwidth}{15cm}
newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist
glsaddkey{unit}{glsentrytext{glslabel}}{glsentryunit}{GLsentryunit}{glsunit}{Glsunit}{GLSunit}
makeglossaries % activate glossaries-package
% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
newglossaryentry{symb:Pi}{name=ensuremath{pi},
description={Geometrical value},
unit={},
type=symbolslist}
newglossaryentry{height}{name=ensuremath{h},
description={Height of tower},
unit={si{m}},
type=symbolslist}
newglossaryentry{energyconsump}{name=ensuremath{P},
description={Energy consumption},
unit={si{kW}},
type=symbolslist}
newglossaryentry{Eficiency}{name=ensuremath{eta},
description={Useful portion of work},
unit={si{}},
type=symbolslist}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{0.6glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Simbolo & bfseries Description & bfseries Unit \
hline
endhead}
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsunit{##1} tabularnewline
}
}
begin{document}
glsaddall
%printglossary[type=acronymtype,style=long] % list of acronyms
printglossary[type=symbolslist,style=symbunitlong,title={Lista de Símbolos}] % list of symbols
% printglossary[type=main] % main glossary
end{document}
And the second one, that sorts but I can't add units to.
How to effectively use List of Symbols for a thesis?
documentclass{report}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
Really sorry to bother, I'm new in Latex and I've been stuck with this for a while now.
symbols glossaries nomenclature
add a comment |
I would like to create a symbols list using makeglossaries, but, it has to be ordered and the symbols must have their respective units too.
On the quest for a solution to my issue I came across two answers that contain what I want but both only have one of the desired outcomes.
1st- Symbols with units but no sorting (ode taken from glossaries: How to customize list of symbols with additional column for units?
documentclass{book}
usepackage{siunitx}
usepackage[symbols,nogroupskip,nonumberlist,automake]{glossaries-extra} % use glossaries-package
usepackage{subfiles}
setlength{glsdescwidth}{15cm}
newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist
glsaddkey{unit}{glsentrytext{glslabel}}{glsentryunit}{GLsentryunit}{glsunit}{Glsunit}{GLSunit}
makeglossaries % activate glossaries-package
% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
newglossaryentry{symb:Pi}{name=ensuremath{pi},
description={Geometrical value},
unit={},
type=symbolslist}
newglossaryentry{height}{name=ensuremath{h},
description={Height of tower},
unit={si{m}},
type=symbolslist}
newglossaryentry{energyconsump}{name=ensuremath{P},
description={Energy consumption},
unit={si{kW}},
type=symbolslist}
newglossaryentry{Eficiency}{name=ensuremath{eta},
description={Useful portion of work},
unit={si{}},
type=symbolslist}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{0.6glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Simbolo & bfseries Description & bfseries Unit \
hline
endhead}
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsunit{##1} tabularnewline
}
}
begin{document}
glsaddall
%printglossary[type=acronymtype,style=long] % list of acronyms
printglossary[type=symbolslist,style=symbunitlong,title={Lista de Símbolos}] % list of symbols
% printglossary[type=main] % main glossary
end{document}
And the second one, that sorts but I can't add units to.
How to effectively use List of Symbols for a thesis?
documentclass{report}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
Really sorry to bother, I'm new in Latex and I've been stuck with this for a while now.
symbols glossaries nomenclature
How do you want the symbols ordered? (E.g. Latin then Greek, or ordered alphabetically by description.) You can add units to the second example. Just add them to the optional argument, e.g.glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
or (with theunit
key defined as per the first example)glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
.
– Nicola Talbot
Aug 22 '18 at 18:16
@NicolaTalbot I would like to have them ordered in the following manner, Latin then Greek. I'll try to do as you said. Thank you very much.
– adriano junior
Aug 22 '18 at 20:10
@NicolaTalbot I added the optional argument to the second example (as it is the ordered one) but it just does not show the unit. With the second example, however, it completely ignores the 'glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}' line.
– adriano junior
Aug 22 '18 at 20:28
add a comment |
I would like to create a symbols list using makeglossaries, but, it has to be ordered and the symbols must have their respective units too.
On the quest for a solution to my issue I came across two answers that contain what I want but both only have one of the desired outcomes.
1st- Symbols with units but no sorting (ode taken from glossaries: How to customize list of symbols with additional column for units?
documentclass{book}
usepackage{siunitx}
usepackage[symbols,nogroupskip,nonumberlist,automake]{glossaries-extra} % use glossaries-package
usepackage{subfiles}
setlength{glsdescwidth}{15cm}
newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist
glsaddkey{unit}{glsentrytext{glslabel}}{glsentryunit}{GLsentryunit}{glsunit}{Glsunit}{GLSunit}
makeglossaries % activate glossaries-package
% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
newglossaryentry{symb:Pi}{name=ensuremath{pi},
description={Geometrical value},
unit={},
type=symbolslist}
newglossaryentry{height}{name=ensuremath{h},
description={Height of tower},
unit={si{m}},
type=symbolslist}
newglossaryentry{energyconsump}{name=ensuremath{P},
description={Energy consumption},
unit={si{kW}},
type=symbolslist}
newglossaryentry{Eficiency}{name=ensuremath{eta},
description={Useful portion of work},
unit={si{}},
type=symbolslist}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{0.6glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Simbolo & bfseries Description & bfseries Unit \
hline
endhead}
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsunit{##1} tabularnewline
}
}
begin{document}
glsaddall
%printglossary[type=acronymtype,style=long] % list of acronyms
printglossary[type=symbolslist,style=symbunitlong,title={Lista de Símbolos}] % list of symbols
% printglossary[type=main] % main glossary
end{document}
And the second one, that sorts but I can't add units to.
How to effectively use List of Symbols for a thesis?
documentclass{report}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
Really sorry to bother, I'm new in Latex and I've been stuck with this for a while now.
symbols glossaries nomenclature
I would like to create a symbols list using makeglossaries, but, it has to be ordered and the symbols must have their respective units too.
On the quest for a solution to my issue I came across two answers that contain what I want but both only have one of the desired outcomes.
1st- Symbols with units but no sorting (ode taken from glossaries: How to customize list of symbols with additional column for units?
documentclass{book}
usepackage{siunitx}
usepackage[symbols,nogroupskip,nonumberlist,automake]{glossaries-extra} % use glossaries-package
usepackage{subfiles}
setlength{glsdescwidth}{15cm}
newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create add. symbolslist
glsaddkey{unit}{glsentrytext{glslabel}}{glsentryunit}{GLsentryunit}{glsunit}{Glsunit}{GLSunit}
makeglossaries % activate glossaries-package
% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================
newglossaryentry{symb:Pi}{name=ensuremath{pi},
description={Geometrical value},
unit={},
type=symbolslist}
newglossaryentry{height}{name=ensuremath{h},
description={Height of tower},
unit={si{m}},
type=symbolslist}
newglossaryentry{energyconsump}{name=ensuremath{P},
description={Energy consumption},
unit={si{kW}},
type=symbolslist}
newglossaryentry{Eficiency}{name=ensuremath{eta},
description={Useful portion of work},
unit={si{}},
type=symbolslist}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{0.6glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Simbolo & bfseries Description & bfseries Unit \
hline
endhead}
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsunit{##1} tabularnewline
}
}
begin{document}
glsaddall
%printglossary[type=acronymtype,style=long] % list of acronyms
printglossary[type=symbolslist,style=symbunitlong,title={Lista de Símbolos}] % list of symbols
% printglossary[type=main] % main glossary
end{document}
And the second one, that sorts but I can't add units to.
How to effectively use List of Symbols for a thesis?
documentclass{report}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
Really sorry to bother, I'm new in Latex and I've been stuck with this for a while now.
symbols glossaries nomenclature
symbols glossaries nomenclature
asked Aug 22 '18 at 17:38
adriano junioradriano junior
353
353
How do you want the symbols ordered? (E.g. Latin then Greek, or ordered alphabetically by description.) You can add units to the second example. Just add them to the optional argument, e.g.glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
or (with theunit
key defined as per the first example)glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
.
– Nicola Talbot
Aug 22 '18 at 18:16
@NicolaTalbot I would like to have them ordered in the following manner, Latin then Greek. I'll try to do as you said. Thank you very much.
– adriano junior
Aug 22 '18 at 20:10
@NicolaTalbot I added the optional argument to the second example (as it is the ordered one) but it just does not show the unit. With the second example, however, it completely ignores the 'glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}' line.
– adriano junior
Aug 22 '18 at 20:28
add a comment |
How do you want the symbols ordered? (E.g. Latin then Greek, or ordered alphabetically by description.) You can add units to the second example. Just add them to the optional argument, e.g.glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
or (with theunit
key defined as per the first example)glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
.
– Nicola Talbot
Aug 22 '18 at 18:16
@NicolaTalbot I would like to have them ordered in the following manner, Latin then Greek. I'll try to do as you said. Thank you very much.
– adriano junior
Aug 22 '18 at 20:10
@NicolaTalbot I added the optional argument to the second example (as it is the ordered one) but it just does not show the unit. With the second example, however, it completely ignores the 'glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}' line.
– adriano junior
Aug 22 '18 at 20:28
How do you want the symbols ordered? (E.g. Latin then Greek, or ordered alphabetically by description.) You can add units to the second example. Just add them to the optional argument, e.g.
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
or (with the unit
key defined as per the first example) glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
.– Nicola Talbot
Aug 22 '18 at 18:16
How do you want the symbols ordered? (E.g. Latin then Greek, or ordered alphabetically by description.) You can add units to the second example. Just add them to the optional argument, e.g.
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
or (with the unit
key defined as per the first example) glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
.– Nicola Talbot
Aug 22 '18 at 18:16
@NicolaTalbot I would like to have them ordered in the following manner, Latin then Greek. I'll try to do as you said. Thank you very much.
– adriano junior
Aug 22 '18 at 20:10
@NicolaTalbot I would like to have them ordered in the following manner, Latin then Greek. I'll try to do as you said. Thank you very much.
– adriano junior
Aug 22 '18 at 20:10
@NicolaTalbot I added the optional argument to the second example (as it is the ordered one) but it just does not show the unit. With the second example, however, it completely ignores the 'glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}' line.
– adriano junior
Aug 22 '18 at 20:28
@NicolaTalbot I added the optional argument to the second example (as it is the ordered one) but it just does not show the unit. With the second example, however, it completely ignores the 'glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}' line.
– adriano junior
Aug 22 '18 at 20:28
add a comment |
1 Answer
1
active
oldest
votes
Your second example uses the long
glossary style (set with style=long
in the optional argument of printunsrtglossary
). This only shows the term (e.g. ensuremath{x}
) and the description (e.g. position
) but it doesn't show any other information (except the location list, which isn't present in that example). You not only need to add the units but also provide a style which will show them.
Some of the predefined styles show the symbol
field as well, so if you use this field to store the unit, then you can just use a style that shows the symbol. Table 15.1 in the glossaries
user manual indciates which styles show the symbol.
For example,
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position},symbol={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},symbol={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},symbol={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},symbol={si{N}}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$. Reference unit: $glssymbol{v}$.
end{document}
This produces:
This actually has four columns, but the fourth is empty as there's no location list. The glssymbol
command works like gls
but displays the symbol value (unit, in this case).
If you'd rather have a custom unit
key, instead of using the provided symbol
key, you can add one as in your first example. There are two commands that can add a new key: glsaddkey
and glsaddstoragekey
. It depends whether you want to use a command like glssymbol
in the above example. If you do, then you need:
glsaddkey{unit}{}{glsentryunit}{Glsentryunit}{glsunit}{Glsunit}{GLSunit}
(The case-changing commands don't make much sense for units, but the syntax requires them.) If you only need the unit to show in the list of symbols then you can do:
glsaddstoragekey{unit}{}{glsentryunit}
You also need to use glsnoexpandfields
to avoid problems caused by expansion.
You can use the glossary style in your first example, but it ought to use glsentryunit
instead of glsunit
:
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
The width of the description column is given by glsdescwidth
. You can change this if it's the wrong size. For example:
setlength{glsdescwidth}{.5textwidth}
which makes it half the available text width or you can use an absolute value:
setlength{glsdescwidth}{3in}
Alternatively, you can just change all the columns to l
if you have short descriptions:
renewenvironment{theglossary}%
{begin{longtable}{lll}}%
{end{longtable}}%
Complete example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
% new keys must be defined before use
glsaddstoragekey{unit}{}{glsentryunit}
glsnoexpandfields
glsxtrnewsymbol[description={position},unit={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},unit={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},unit={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},unit={si{N}}]{F}{ensuremath{F}}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
The list of symbols looks like:
This deals with how to display the units in the list of symbols, but the ordering is performed manually by defining each symbol in the desired order. If you want to automatically order first by Latin and then by Greek, you need to use an extra tool. The best one for this task is bib2gls
because it recognises Greek commands such as alpha
, but for this you need to define all your symbols in a .bib
file.
For example, symbols.bib
:
% Encoding: UTF-8
@symbol{alpha,
unit= {si{radianpersecondsquared}},
name = {ensuremath{alpha}},
description = {angular acceleration}
}
@symbol{x,
unit = {si{m}},
name = {ensuremath{x}},
description = {position}
}
@symbol{v,
unit = {si{metrepersecond}},
name = {ensuremath{v}},
description = {velocity}
}
@symbol{a,
unit = {si{metrepersecondsquared}},
name = {ensuremath{a}},
description = {acceleration}
}
@symbol{t,
unit = {si{s}},
name = {ensuremath{t}},
description = {time}
}
@symbol{F,
unit = {si{N}},
name = {ensuremath{F}},
description = {force}
}
The document:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
% new keys must be defined before GlsXtrLoadResources
glsaddstoragekey{unit}{}{glsentryunit}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols % put these terms in the symbols list
]
% Define new glossary style
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$.
end{document}
If the document is called test.tex
then the document build is:
pdflatex test
bib2gls test
pdflatex test
(If you need help integrating this with your text editor, see Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)
The sort=letter-nocase
option performs a case-insensitive character sort, so the Latin characters will naturally end up before the Greek characters. The result is:
If you prefer to just use the long4col
style, then the fourth column will now contain the location lists (where the term was used in the document). For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol}% convert unit key to symbol
]
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
The option field-aliases={unit=symbol}
makes bib2gls
treat the custom unit
field as though it was actually the symbol
field, so there's no need to change the symbols.bib
file. (Without this alias, bib2gls
will ignore the unit
field, since the unit
key is no longer defined in the document.)
You can omit the location list with either the nonumberlist
option. For example:
usepackage[record,symbols,nonumberlist]{glossaries-extra}
or
printunsrtglossary[type=symbols,style=long4col,nonnumberlist]
Alternatively, you can use save-locations=false
in the resource options:
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
The glossaries-extra
package now comes with a supplementary package glossary-longextra
that provides additional glossary styles that use the longtable
environment. These are more flexible than the long
styles provided with the base glossaries
package, and so are easier to adjust. There are samples of each of the longextra
styles in the glossaries
gallery. (If glossary-longextra.sty
isn't found, try upgrading your glossaries-extra
installation.)
For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols, % create list of symbols
stylemods={longextra} % load glossary-longextra.sty
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
renewcommand{entryname}{Symbol}
renewcommand{symbolname}{Unit}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long-name-desc-sym]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
This uses the long-name-desc-sym
style that has the name in the first column, the description in the second column and the symbol in the third column. The header text for the name and symbol columns are given by the language-sensitive commands entryname
and symbolname
. These are redefined in the above example. This style doesn't show the location list, so I've instructed bib2gls
to not bother saving the locations (with save-locations=false
).
The column alignments can be changed by redefining glslongextraNameAlign
, for the name column, and glslongextraSymbolAlign
, for the symbol column. For example:
renewcommand{glslongextraNameAlign}{c}
renewcommand{glslongextraSymbolAlign}{r}
If you want a different column ordering, you can just use one of the other styles. For example, the long-name-sym-desc
has the name in the first column, the symbol in the second column and the description in the third column.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447208%2fordered-symbols-list-with-units%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your second example uses the long
glossary style (set with style=long
in the optional argument of printunsrtglossary
). This only shows the term (e.g. ensuremath{x}
) and the description (e.g. position
) but it doesn't show any other information (except the location list, which isn't present in that example). You not only need to add the units but also provide a style which will show them.
Some of the predefined styles show the symbol
field as well, so if you use this field to store the unit, then you can just use a style that shows the symbol. Table 15.1 in the glossaries
user manual indciates which styles show the symbol.
For example,
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position},symbol={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},symbol={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},symbol={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},symbol={si{N}}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$. Reference unit: $glssymbol{v}$.
end{document}
This produces:
This actually has four columns, but the fourth is empty as there's no location list. The glssymbol
command works like gls
but displays the symbol value (unit, in this case).
If you'd rather have a custom unit
key, instead of using the provided symbol
key, you can add one as in your first example. There are two commands that can add a new key: glsaddkey
and glsaddstoragekey
. It depends whether you want to use a command like glssymbol
in the above example. If you do, then you need:
glsaddkey{unit}{}{glsentryunit}{Glsentryunit}{glsunit}{Glsunit}{GLSunit}
(The case-changing commands don't make much sense for units, but the syntax requires them.) If you only need the unit to show in the list of symbols then you can do:
glsaddstoragekey{unit}{}{glsentryunit}
You also need to use glsnoexpandfields
to avoid problems caused by expansion.
You can use the glossary style in your first example, but it ought to use glsentryunit
instead of glsunit
:
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
The width of the description column is given by glsdescwidth
. You can change this if it's the wrong size. For example:
setlength{glsdescwidth}{.5textwidth}
which makes it half the available text width or you can use an absolute value:
setlength{glsdescwidth}{3in}
Alternatively, you can just change all the columns to l
if you have short descriptions:
renewenvironment{theglossary}%
{begin{longtable}{lll}}%
{end{longtable}}%
Complete example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
% new keys must be defined before use
glsaddstoragekey{unit}{}{glsentryunit}
glsnoexpandfields
glsxtrnewsymbol[description={position},unit={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},unit={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},unit={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},unit={si{N}}]{F}{ensuremath{F}}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
The list of symbols looks like:
This deals with how to display the units in the list of symbols, but the ordering is performed manually by defining each symbol in the desired order. If you want to automatically order first by Latin and then by Greek, you need to use an extra tool. The best one for this task is bib2gls
because it recognises Greek commands such as alpha
, but for this you need to define all your symbols in a .bib
file.
For example, symbols.bib
:
% Encoding: UTF-8
@symbol{alpha,
unit= {si{radianpersecondsquared}},
name = {ensuremath{alpha}},
description = {angular acceleration}
}
@symbol{x,
unit = {si{m}},
name = {ensuremath{x}},
description = {position}
}
@symbol{v,
unit = {si{metrepersecond}},
name = {ensuremath{v}},
description = {velocity}
}
@symbol{a,
unit = {si{metrepersecondsquared}},
name = {ensuremath{a}},
description = {acceleration}
}
@symbol{t,
unit = {si{s}},
name = {ensuremath{t}},
description = {time}
}
@symbol{F,
unit = {si{N}},
name = {ensuremath{F}},
description = {force}
}
The document:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
% new keys must be defined before GlsXtrLoadResources
glsaddstoragekey{unit}{}{glsentryunit}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols % put these terms in the symbols list
]
% Define new glossary style
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$.
end{document}
If the document is called test.tex
then the document build is:
pdflatex test
bib2gls test
pdflatex test
(If you need help integrating this with your text editor, see Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)
The sort=letter-nocase
option performs a case-insensitive character sort, so the Latin characters will naturally end up before the Greek characters. The result is:
If you prefer to just use the long4col
style, then the fourth column will now contain the location lists (where the term was used in the document). For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol}% convert unit key to symbol
]
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
The option field-aliases={unit=symbol}
makes bib2gls
treat the custom unit
field as though it was actually the symbol
field, so there's no need to change the symbols.bib
file. (Without this alias, bib2gls
will ignore the unit
field, since the unit
key is no longer defined in the document.)
You can omit the location list with either the nonumberlist
option. For example:
usepackage[record,symbols,nonumberlist]{glossaries-extra}
or
printunsrtglossary[type=symbols,style=long4col,nonnumberlist]
Alternatively, you can use save-locations=false
in the resource options:
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
The glossaries-extra
package now comes with a supplementary package glossary-longextra
that provides additional glossary styles that use the longtable
environment. These are more flexible than the long
styles provided with the base glossaries
package, and so are easier to adjust. There are samples of each of the longextra
styles in the glossaries
gallery. (If glossary-longextra.sty
isn't found, try upgrading your glossaries-extra
installation.)
For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols, % create list of symbols
stylemods={longextra} % load glossary-longextra.sty
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
renewcommand{entryname}{Symbol}
renewcommand{symbolname}{Unit}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long-name-desc-sym]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
This uses the long-name-desc-sym
style that has the name in the first column, the description in the second column and the symbol in the third column. The header text for the name and symbol columns are given by the language-sensitive commands entryname
and symbolname
. These are redefined in the above example. This style doesn't show the location list, so I've instructed bib2gls
to not bother saving the locations (with save-locations=false
).
The column alignments can be changed by redefining glslongextraNameAlign
, for the name column, and glslongextraSymbolAlign
, for the symbol column. For example:
renewcommand{glslongextraNameAlign}{c}
renewcommand{glslongextraSymbolAlign}{r}
If you want a different column ordering, you can just use one of the other styles. For example, the long-name-sym-desc
has the name in the first column, the symbol in the second column and the description in the third column.
add a comment |
Your second example uses the long
glossary style (set with style=long
in the optional argument of printunsrtglossary
). This only shows the term (e.g. ensuremath{x}
) and the description (e.g. position
) but it doesn't show any other information (except the location list, which isn't present in that example). You not only need to add the units but also provide a style which will show them.
Some of the predefined styles show the symbol
field as well, so if you use this field to store the unit, then you can just use a style that shows the symbol. Table 15.1 in the glossaries
user manual indciates which styles show the symbol.
For example,
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position},symbol={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},symbol={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},symbol={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},symbol={si{N}}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$. Reference unit: $glssymbol{v}$.
end{document}
This produces:
This actually has four columns, but the fourth is empty as there's no location list. The glssymbol
command works like gls
but displays the symbol value (unit, in this case).
If you'd rather have a custom unit
key, instead of using the provided symbol
key, you can add one as in your first example. There are two commands that can add a new key: glsaddkey
and glsaddstoragekey
. It depends whether you want to use a command like glssymbol
in the above example. If you do, then you need:
glsaddkey{unit}{}{glsentryunit}{Glsentryunit}{glsunit}{Glsunit}{GLSunit}
(The case-changing commands don't make much sense for units, but the syntax requires them.) If you only need the unit to show in the list of symbols then you can do:
glsaddstoragekey{unit}{}{glsentryunit}
You also need to use glsnoexpandfields
to avoid problems caused by expansion.
You can use the glossary style in your first example, but it ought to use glsentryunit
instead of glsunit
:
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
The width of the description column is given by glsdescwidth
. You can change this if it's the wrong size. For example:
setlength{glsdescwidth}{.5textwidth}
which makes it half the available text width or you can use an absolute value:
setlength{glsdescwidth}{3in}
Alternatively, you can just change all the columns to l
if you have short descriptions:
renewenvironment{theglossary}%
{begin{longtable}{lll}}%
{end{longtable}}%
Complete example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
% new keys must be defined before use
glsaddstoragekey{unit}{}{glsentryunit}
glsnoexpandfields
glsxtrnewsymbol[description={position},unit={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},unit={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},unit={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},unit={si{N}}]{F}{ensuremath{F}}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
The list of symbols looks like:
This deals with how to display the units in the list of symbols, but the ordering is performed manually by defining each symbol in the desired order. If you want to automatically order first by Latin and then by Greek, you need to use an extra tool. The best one for this task is bib2gls
because it recognises Greek commands such as alpha
, but for this you need to define all your symbols in a .bib
file.
For example, symbols.bib
:
% Encoding: UTF-8
@symbol{alpha,
unit= {si{radianpersecondsquared}},
name = {ensuremath{alpha}},
description = {angular acceleration}
}
@symbol{x,
unit = {si{m}},
name = {ensuremath{x}},
description = {position}
}
@symbol{v,
unit = {si{metrepersecond}},
name = {ensuremath{v}},
description = {velocity}
}
@symbol{a,
unit = {si{metrepersecondsquared}},
name = {ensuremath{a}},
description = {acceleration}
}
@symbol{t,
unit = {si{s}},
name = {ensuremath{t}},
description = {time}
}
@symbol{F,
unit = {si{N}},
name = {ensuremath{F}},
description = {force}
}
The document:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
% new keys must be defined before GlsXtrLoadResources
glsaddstoragekey{unit}{}{glsentryunit}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols % put these terms in the symbols list
]
% Define new glossary style
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$.
end{document}
If the document is called test.tex
then the document build is:
pdflatex test
bib2gls test
pdflatex test
(If you need help integrating this with your text editor, see Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)
The sort=letter-nocase
option performs a case-insensitive character sort, so the Latin characters will naturally end up before the Greek characters. The result is:
If you prefer to just use the long4col
style, then the fourth column will now contain the location lists (where the term was used in the document). For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol}% convert unit key to symbol
]
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
The option field-aliases={unit=symbol}
makes bib2gls
treat the custom unit
field as though it was actually the symbol
field, so there's no need to change the symbols.bib
file. (Without this alias, bib2gls
will ignore the unit
field, since the unit
key is no longer defined in the document.)
You can omit the location list with either the nonumberlist
option. For example:
usepackage[record,symbols,nonumberlist]{glossaries-extra}
or
printunsrtglossary[type=symbols,style=long4col,nonnumberlist]
Alternatively, you can use save-locations=false
in the resource options:
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
The glossaries-extra
package now comes with a supplementary package glossary-longextra
that provides additional glossary styles that use the longtable
environment. These are more flexible than the long
styles provided with the base glossaries
package, and so are easier to adjust. There are samples of each of the longextra
styles in the glossaries
gallery. (If glossary-longextra.sty
isn't found, try upgrading your glossaries-extra
installation.)
For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols, % create list of symbols
stylemods={longextra} % load glossary-longextra.sty
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
renewcommand{entryname}{Symbol}
renewcommand{symbolname}{Unit}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long-name-desc-sym]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
This uses the long-name-desc-sym
style that has the name in the first column, the description in the second column and the symbol in the third column. The header text for the name and symbol columns are given by the language-sensitive commands entryname
and symbolname
. These are redefined in the above example. This style doesn't show the location list, so I've instructed bib2gls
to not bother saving the locations (with save-locations=false
).
The column alignments can be changed by redefining glslongextraNameAlign
, for the name column, and glslongextraSymbolAlign
, for the symbol column. For example:
renewcommand{glslongextraNameAlign}{c}
renewcommand{glslongextraSymbolAlign}{r}
If you want a different column ordering, you can just use one of the other styles. For example, the long-name-sym-desc
has the name in the first column, the symbol in the second column and the description in the third column.
add a comment |
Your second example uses the long
glossary style (set with style=long
in the optional argument of printunsrtglossary
). This only shows the term (e.g. ensuremath{x}
) and the description (e.g. position
) but it doesn't show any other information (except the location list, which isn't present in that example). You not only need to add the units but also provide a style which will show them.
Some of the predefined styles show the symbol
field as well, so if you use this field to store the unit, then you can just use a style that shows the symbol. Table 15.1 in the glossaries
user manual indciates which styles show the symbol.
For example,
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position},symbol={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},symbol={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},symbol={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},symbol={si{N}}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$. Reference unit: $glssymbol{v}$.
end{document}
This produces:
This actually has four columns, but the fourth is empty as there's no location list. The glssymbol
command works like gls
but displays the symbol value (unit, in this case).
If you'd rather have a custom unit
key, instead of using the provided symbol
key, you can add one as in your first example. There are two commands that can add a new key: glsaddkey
and glsaddstoragekey
. It depends whether you want to use a command like glssymbol
in the above example. If you do, then you need:
glsaddkey{unit}{}{glsentryunit}{Glsentryunit}{glsunit}{Glsunit}{GLSunit}
(The case-changing commands don't make much sense for units, but the syntax requires them.) If you only need the unit to show in the list of symbols then you can do:
glsaddstoragekey{unit}{}{glsentryunit}
You also need to use glsnoexpandfields
to avoid problems caused by expansion.
You can use the glossary style in your first example, but it ought to use glsentryunit
instead of glsunit
:
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
The width of the description column is given by glsdescwidth
. You can change this if it's the wrong size. For example:
setlength{glsdescwidth}{.5textwidth}
which makes it half the available text width or you can use an absolute value:
setlength{glsdescwidth}{3in}
Alternatively, you can just change all the columns to l
if you have short descriptions:
renewenvironment{theglossary}%
{begin{longtable}{lll}}%
{end{longtable}}%
Complete example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
% new keys must be defined before use
glsaddstoragekey{unit}{}{glsentryunit}
glsnoexpandfields
glsxtrnewsymbol[description={position},unit={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},unit={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},unit={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},unit={si{N}}]{F}{ensuremath{F}}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
The list of symbols looks like:
This deals with how to display the units in the list of symbols, but the ordering is performed manually by defining each symbol in the desired order. If you want to automatically order first by Latin and then by Greek, you need to use an extra tool. The best one for this task is bib2gls
because it recognises Greek commands such as alpha
, but for this you need to define all your symbols in a .bib
file.
For example, symbols.bib
:
% Encoding: UTF-8
@symbol{alpha,
unit= {si{radianpersecondsquared}},
name = {ensuremath{alpha}},
description = {angular acceleration}
}
@symbol{x,
unit = {si{m}},
name = {ensuremath{x}},
description = {position}
}
@symbol{v,
unit = {si{metrepersecond}},
name = {ensuremath{v}},
description = {velocity}
}
@symbol{a,
unit = {si{metrepersecondsquared}},
name = {ensuremath{a}},
description = {acceleration}
}
@symbol{t,
unit = {si{s}},
name = {ensuremath{t}},
description = {time}
}
@symbol{F,
unit = {si{N}},
name = {ensuremath{F}},
description = {force}
}
The document:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
% new keys must be defined before GlsXtrLoadResources
glsaddstoragekey{unit}{}{glsentryunit}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols % put these terms in the symbols list
]
% Define new glossary style
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$.
end{document}
If the document is called test.tex
then the document build is:
pdflatex test
bib2gls test
pdflatex test
(If you need help integrating this with your text editor, see Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)
The sort=letter-nocase
option performs a case-insensitive character sort, so the Latin characters will naturally end up before the Greek characters. The result is:
If you prefer to just use the long4col
style, then the fourth column will now contain the location lists (where the term was used in the document). For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol}% convert unit key to symbol
]
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
The option field-aliases={unit=symbol}
makes bib2gls
treat the custom unit
field as though it was actually the symbol
field, so there's no need to change the symbols.bib
file. (Without this alias, bib2gls
will ignore the unit
field, since the unit
key is no longer defined in the document.)
You can omit the location list with either the nonumberlist
option. For example:
usepackage[record,symbols,nonumberlist]{glossaries-extra}
or
printunsrtglossary[type=symbols,style=long4col,nonnumberlist]
Alternatively, you can use save-locations=false
in the resource options:
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
The glossaries-extra
package now comes with a supplementary package glossary-longextra
that provides additional glossary styles that use the longtable
environment. These are more flexible than the long
styles provided with the base glossaries
package, and so are easier to adjust. There are samples of each of the longextra
styles in the glossaries
gallery. (If glossary-longextra.sty
isn't found, try upgrading your glossaries-extra
installation.)
For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols, % create list of symbols
stylemods={longextra} % load glossary-longextra.sty
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
renewcommand{entryname}{Symbol}
renewcommand{symbolname}{Unit}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long-name-desc-sym]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
This uses the long-name-desc-sym
style that has the name in the first column, the description in the second column and the symbol in the third column. The header text for the name and symbol columns are given by the language-sensitive commands entryname
and symbolname
. These are redefined in the above example. This style doesn't show the location list, so I've instructed bib2gls
to not bother saving the locations (with save-locations=false
).
The column alignments can be changed by redefining glslongextraNameAlign
, for the name column, and glslongextraSymbolAlign
, for the symbol column. For example:
renewcommand{glslongextraNameAlign}{c}
renewcommand{glslongextraSymbolAlign}{r}
If you want a different column ordering, you can just use one of the other styles. For example, the long-name-sym-desc
has the name in the first column, the symbol in the second column and the description in the third column.
Your second example uses the long
glossary style (set with style=long
in the optional argument of printunsrtglossary
). This only shows the term (e.g. ensuremath{x}
) and the description (e.g. position
) but it doesn't show any other information (except the location list, which isn't present in that example). You not only need to add the units but also provide a style which will show them.
Some of the predefined styles show the symbol
field as well, so if you use this field to store the unit, then you can just use a style that shows the symbol. Table 15.1 in the glossaries
user manual indciates which styles show the symbol.
For example,
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
glsxtrnewsymbol[description={position},symbol={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},symbol={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},symbol={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},symbol={si{N}}]{F}{ensuremath{F}}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$. Reference unit: $glssymbol{v}$.
end{document}
This produces:
This actually has four columns, but the fourth is empty as there's no location list. The glssymbol
command works like gls
but displays the symbol value (unit, in this case).
If you'd rather have a custom unit
key, instead of using the provided symbol
key, you can add one as in your first example. There are two commands that can add a new key: glsaddkey
and glsaddstoragekey
. It depends whether you want to use a command like glssymbol
in the above example. If you do, then you need:
glsaddkey{unit}{}{glsentryunit}{Glsentryunit}{glsunit}{Glsunit}{GLSunit}
(The case-changing commands don't make much sense for units, but the syntax requires them.) If you only need the unit to show in the list of symbols then you can do:
glsaddstoragekey{unit}{}{glsentryunit}
You also need to use glsnoexpandfields
to avoid problems caused by expansion.
You can use the glossary style in your first example, but it ought to use glsentryunit
instead of glsunit
:
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
The width of the description column is given by glsdescwidth
. You can change this if it's the wrong size. For example:
setlength{glsdescwidth}{.5textwidth}
which makes it half the available text width or you can use an absolute value:
setlength{glsdescwidth}{3in}
Alternatively, you can just change all the columns to l
if you have short descriptions:
renewenvironment{theglossary}%
{begin{longtable}{lll}}%
{end{longtable}}%
Complete example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[symbols,nogroupskip,sort=none]{glossaries-extra}
% new keys must be defined before use
glsaddstoragekey{unit}{}{glsentryunit}
glsnoexpandfields
glsxtrnewsymbol[description={position},unit={si{m}}]{x}{ensuremath{x}}
glsxtrnewsymbol[description={velocity},unit={si{metrepersecond}}]{v}{ensuremath{v}}
glsxtrnewsymbol[description={acceleration},unit={si{metrepersecondsquared}}]{a}{ensuremath{a}}
glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
glsxtrnewsymbol[description={force},unit={si{N}}]{F}{ensuremath{F}}
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$.
end{document}
The list of symbols looks like:
This deals with how to display the units in the list of symbols, but the ordering is performed manually by defining each symbol in the desired order. If you want to automatically order first by Latin and then by Greek, you need to use an extra tool. The best one for this task is bib2gls
because it recognises Greek commands such as alpha
, but for this you need to define all your symbols in a .bib
file.
For example, symbols.bib
:
% Encoding: UTF-8
@symbol{alpha,
unit= {si{radianpersecondsquared}},
name = {ensuremath{alpha}},
description = {angular acceleration}
}
@symbol{x,
unit = {si{m}},
name = {ensuremath{x}},
description = {position}
}
@symbol{v,
unit = {si{metrepersecond}},
name = {ensuremath{v}},
description = {velocity}
}
@symbol{a,
unit = {si{metrepersecondsquared}},
name = {ensuremath{a}},
description = {acceleration}
}
@symbol{t,
unit = {si{s}},
name = {ensuremath{t}},
description = {time}
}
@symbol{F,
unit = {si{N}},
name = {ensuremath{F}},
description = {force}
}
The document:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
% new keys must be defined before GlsXtrLoadResources
glsaddstoragekey{unit}{}{glsentryunit}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols % put these terms in the symbols list
]
% Define new glossary style
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% Change the table type --> 3 columns
begin{longtable}{lp{glsdescwidth}>{centeringarraybackslash}p{2cm}}}%
{end{longtable}}%
%
renewcommand*{glossaryheader}{% Change the table header
bfseries Symbol & bfseries Description & bfseries Unit\hline
endhead}%
renewcommand*{glossentry}[2]{% Change the displayed items
glstarget{##1}{glossentryname{##1}} %
& glossentrydesc{##1}% Description
& glsentryunit{##1} tabularnewline
}%
}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=symbunitlong]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$.
end{document}
If the document is called test.tex
then the document build is:
pdflatex test
bib2gls test
pdflatex test
(If you need help integrating this with your text editor, see Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.)
The sort=letter-nocase
option performs a case-insensitive character sort, so the Latin characters will naturally end up before the Greek characters. The result is:
If you prefer to just use the long4col
style, then the fourth column will now contain the location lists (where the term was used in the document). For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols % create list of symbols
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol}% convert unit key to symbol
]
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long4col]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
The option field-aliases={unit=symbol}
makes bib2gls
treat the custom unit
field as though it was actually the symbol
field, so there's no need to change the symbols.bib
file. (Without this alias, bib2gls
will ignore the unit
field, since the unit
key is no longer defined in the document.)
You can omit the location list with either the nonumberlist
option. For example:
usepackage[record,symbols,nonumberlist]{glossaries-extra}
or
printunsrtglossary[type=symbols,style=long4col,nonnumberlist]
Alternatively, you can use save-locations=false
in the resource options:
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
The glossaries-extra
package now comes with a supplementary package glossary-longextra
that provides additional glossary styles that use the longtable
environment. These are more flexible than the long
styles provided with the base glossaries
package, and so are easier to adjust. There are samples of each of the longextra
styles in the glossaries
gallery. (If glossary-longextra.sty
isn't found, try upgrading your glossaries-extra
installation.)
For example:
documentclass{report}
usepackage{siunitx}
usepackage[colorlinks]{hyperref}
usepackage[record,% using bib2gls
symbols, % create list of symbols
stylemods={longextra} % load glossary-longextra.sty
]{glossaries-extra}
GlsXtrLoadResources[
src={symbols}, % data in symbols.bib
sort-field={name}, % sort by name field
sort={letter-nocase}, % case-insensitive letter sort
type=symbols, % put these terms in the symbols list
field-aliases={unit=symbol},% convert unit key to symbol
save-locations=false % don't save location lists
]
% change column headers:
renewcommand{entryname}{Symbol}
renewcommand{symbolname}{Unit}
begin{document}
tableofcontents
printunsrtglossary[type=symbols,style=long-name-desc-sym]
chapter{Sample}
Reference symbols: $gls{x}$, $gls{v}$, $gls{a}$, $gls{t}$,
$gls{F}$ and $gls{alpha}$. Unit for $gls{v}$: $glssymbol{v}$.
end{document}
This uses the long-name-desc-sym
style that has the name in the first column, the description in the second column and the symbol in the third column. The header text for the name and symbol columns are given by the language-sensitive commands entryname
and symbolname
. These are redefined in the above example. This style doesn't show the location list, so I've instructed bib2gls
to not bother saving the locations (with save-locations=false
).
The column alignments can be changed by redefining glslongextraNameAlign
, for the name column, and glslongextraSymbolAlign
, for the symbol column. For example:
renewcommand{glslongextraNameAlign}{c}
renewcommand{glslongextraSymbolAlign}{r}
If you want a different column ordering, you can just use one of the other styles. For example, the long-name-sym-desc
has the name in the first column, the symbol in the second column and the description in the third column.
edited Feb 6 at 10:50
answered Aug 22 '18 at 22:12
Nicola TalbotNicola Talbot
34.2k258105
34.2k258105
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447208%2fordered-symbols-list-with-units%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How do you want the symbols ordered? (E.g. Latin then Greek, or ordered alphabetically by description.) You can add units to the second example. Just add them to the optional argument, e.g.
glsxtrnewsymbol[description={time},symbol={si{s}}]{t}{ensuremath{t}}
or (with theunit
key defined as per the first example)glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}
.– Nicola Talbot
Aug 22 '18 at 18:16
@NicolaTalbot I would like to have them ordered in the following manner, Latin then Greek. I'll try to do as you said. Thank you very much.
– adriano junior
Aug 22 '18 at 20:10
@NicolaTalbot I added the optional argument to the second example (as it is the ordered one) but it just does not show the unit. With the second example, however, it completely ignores the 'glsxtrnewsymbol[description={time},unit={si{s}}]{t}{ensuremath{t}}' line.
– adriano junior
Aug 22 '18 at 20:28