TeX - LaTeX Asked by Kapa on April 21, 2021
I want to create a glossary with 3 columns (I got this already) and I want to subdivide it into different subsections (like Roman and Greek letters). The section should be left-aligned and bold.
Here is the MWE
documentclass[12pt,oneside,listof=totoc,bibliography=totoc,BCOR=15mm,DIV=12,headings=normal,numbers=noendperiod,parskip=half]{scrbook}
usepackage{siunitx}
usepackage[acronym,toc,automake,nogroupskip]{glossaries} % automake: glossary automatically compiled each time pdflatex is run
setlength{glsdescwidth}{textwidth} % total width of glossary
newglossary[slg]{symbolslist}{syi}{syg}{Symbolslist} % create new symbolslist
glsaddkey{unit}{glsentrytext{glslabel}}{glsentryunit}{GLsentryunit}{glsunit}{Glsunit}{GLSunit} % add unit-entry to list of symbols
glssetnoexpandfield{unit} % field for unit does never expand
makeglossaries % calls backend to sort and typeset glossries, list of acronyms, list of symbols etc.
newglossarystyle{symbunitlong}{%
setglossarystyle{long3col}% base this style on the list style
renewenvironment{theglossary}{% change the table type to three columns
begin{longtable}{lp{0.75glsdescwidth}>{arraybackslash}p{1.3cm}}}%
{end{longtable}}%
renewcommand*{glossentry}[2]{% change the displayed items
glstarget{##1}{glossentryname{##1}} % symbol
& glossentrydesc{##1}% description
& glsunit{##1} tabularnewline % unit
}
}
% defining the two sections
newglossaryentry{header1}{name={Section 1},description={},sort=000,unit={}}
newglossaryentry{header2}{name={Sectino 2},description={},sort=001,unit={}}
% adding two entries
newglossaryentry{firstEntry}{name=ensuremath{a_1},
sort=a1,
description={Some description},
unit={si{-}},
type=symbolslist,
parent=header1}
newglossaryentry{secondEntry}{name=ensuremath{b_2},
sort=b2,
description={Some description},
unit={si{-}},
type=symbolslist,
parent=header2}
begin{document}
glsaddall
printglossary[type=symbolslist,style=symbunitlong,title={List of Important Symbols}]
Hello World
end{document}
Defining the two “Sections” at the beginning destroys the entries coming afterwards. Everything works fine if I do not define a parent. Can you help me? Thanks 🙂
You forgot to define how subentries should be displayed. If you add
renewcommand{subglossentry}[3]{%
glstarget{##2}{glossentryname{##2}} &
glossentrydesc{##2} &
glsunit{##2} tabularnewline
}%
to your definition of symbunitlong
, the subentries will show up as (I suspect that) you expect.
This is not really a good way to "create sections" in your glossary, though. You should rather create two separate glossaries (e.g. one for Roman and one for Greek symbols). These can then easily be configured and output separately. (If you need a basic example for how to do this, you can have a look at this answer. The question is a different one, but the example shows pretty much what you are looking for, I think.)
Correct answer by schtandard on April 21, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP