我想创造不同的glossaries
更大文档的章节:
- 词汇表
- 缩略词列表
- 符号列表
到目前为止一切顺利。如果我只有一个大符号列表,我就可以正常工作。
当我在不同的子列表中使用多个符号列表时,例如标量、向量、矩阵等,就会出现问题。我为每个子列表创建了一个单独的列表。因此,我希望有一个章节toc
条目符号列表并且每个子列表都有一个部分。但是,每个子列表section=chapter
的选项\usepackage{glossaries}
都会打印为单独的章节。这对于词汇表和首字母缩略词来说没问题,但对于符号子列表来说就不行了。
有没有办法为每个\printglossary[<options>]
命令单独定义节级别,而不是全局定义\usepackage[<options>]{glossaries}
?或者还有其他解决方法?我已经尝试修改\glossarysection
词汇表样式mysymbolstyle
,但无法更改父目录级别。
平均能量损失
另存为doc.tex
\documentclass[a4paper,10pt]{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{siunitx}
\usepackage{tabu}
\usepackage[
acronym,
toc,
section=chapter,% chapter|section
]{glossaries}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Redefine package options %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand*{\glspostdescription}{\dotfill}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Own styles %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% -----------------
% Acronym-styles
% -----------------
\newglossarystyle{myacronymstyle}{%
\renewenvironment{theglossary}%
{\begin{longtabu} to \linewidth {lX}}%
{\end{longtabu}}%
% Header line
\renewcommand*{\glossaryheader}{}%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupskip}{\tabularnewline}% What to do between groups
\renewcommand*{\glossaryentryfield}[5]{%
\glsentryitem{##1}\glstarget{##1}{##2}
& ##3\glspostdescription ##5% Description
\\% end of row
}
}
% -----------------
% Symbols-styles
% -----------------
\newglossarystyle{mysymbolstyle}{%
%\renewcommand{\glossarysection}[2][]{}% no title
\renewcommand*{\glsclearpage}{}% avoid page break before glossary
\renewenvironment{theglossary}%
{\begin{longtabu} to \linewidth {clXc}}%
{\end{longtabu}}%
% Header line
\renewcommand*{\glossaryheader}{%
% Requires booktabs
%\toprule%
\textbf{Symbol} & \textbf{Name} & \textbf{Description} & \textbf{Unit}%
\tabularnewline%
\tabularnewline%
%\midrule%
\endhead%
%\bottomrule%
\endfoot%
}%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupskip}{\tabularnewline}% What to do between groups
\renewcommand*{\glossentry}[1]{%
\glsentryitem{##1}% Entry number if required
\glstarget{##1}{\glossentrysymbol{##1}} &
%\glossentrysymbol{##1} & % Symbol
\glossentryname{##1} & % Name
\glossentrydesc{##1} & % Description
\glsentryuseri{##1}% % Unit in User1-Variable
\tabularnewline%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Own glossaries %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newglossary[slg1]{onelist}{syi1}{syg1}{Category 1 units}
\newglossary[slg2]{twolist}{syi2}{syg2}{Category 2 units}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Symbols %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------
% Category 1
%------------------
\newglossaryentry{symb:length}{%
symbol ={$l$},%
name ={Length},%
description ={Length Description},%
user1 ={\ensuremath{\protect\si{\protect\metre}}},%
type =onelist,%
sort =length,%
}
\newglossaryentry{symb:width}{%
symbol ={$w$},%
name ={Width},%
description ={Width Description},%
user1 ={\ensuremath{\protect\si{\protect\metre}}},%
type =onelist,%
sort =length,%
}
%------------------
% Category 2
%------------------
\newglossaryentry{symb:tmat}{%
symbol ={$\mathbf{T}$},%
name ={Test},%
description ={Test description},%
user1 ={$1$},%
type =twolist,%
sort =test,%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Acronyms %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newacronym{XYZ}{XYZ}{Explanation of XYZ abbreviation\protect\glsadd{gls:XYZ}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Glossary %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newglossaryentry{gls:XYZ}{
name=Name of XYZ,
description={%
Description of XYZ
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make glossaries %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeglossaries
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{Chapter 1}
\lipsum[1-3]
\chapter{Chapter 2}
\lipsum[4-5]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Glossaries %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glsaddall
\printglossary[style=altlist,title=Glossary]
\printglossary[type=\acronymtype,style=myacronymstyle]
%Symbole ausgeben
\chapter*{List of symbols}
\addcontentsline{toc}{chapter}{List of symbols}
\printglossary[type=onelist,style=mysymbolstyle,nonumberlist,title=test 1]
\printglossary[type=twolist,style=mysymbolstyle,nonumberlist,title=test 2]
\end{document}
汇编
pdflatex doc.tex
makeindex -s doc.ist -t doc.alg -o doc.acr doc.acn
makeindex -s doc.ist -t doc.glg -o doc.gls doc.glo
makeindex -s doc.ist -t doc.slg1 -o doc.syi1 doc.syg1
makeindex -s doc.ist -t doc.slg2 -o doc.syi2 doc.syg2
pdflatex doc.tex
pdflatex doc.tex
答案1
您可以通过以下方式更改文档内的级别\setglossarysection{section}
:
\printglossary[style=altlist,title=Glossary]
\printglossary[type=\acronymtype,style=myacronymstyle]
%Symbole ausgeben
\chapter*{List of symbols}
\addcontentsline{toc}{chapter}{List of symbols}
\setglossarysection{section}% <- added
\printglossary[type=onelist,style=mysymbolstyle,nonumberlist,title=test 1]
\printglossary[type=twolist,style=mysymbolstyle,nonumberlist,title=test 2]
代码:
\documentclass[a4paper,10pt]{scrreprt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{siunitx}
\usepackage{tabu}
\usepackage[
acronym,
toc,
section=chapter,% chapter|section
]{glossaries}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Redefine package options %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand*{\glspostdescription}{\dotfill}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Own styles %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% -----------------
% Acronym-styles
% -----------------
\newglossarystyle{myacronymstyle}{%
\renewenvironment{theglossary}%
{\begin{longtabu} to \linewidth {lX}}%
{\end{longtabu}}%
% Header line
\renewcommand*{\glossaryheader}{}%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupskip}{\tabularnewline}% What to do between groups
\renewcommand*{\glossaryentryfield}[5]{%
\glsentryitem{##1}\glstarget{##1}{##2}
& ##3\glspostdescription ##5% Description
\\% end of row
}
}
% -----------------
% Symbols-styles
% -----------------
\newglossarystyle{mysymbolstyle}{%
%\renewcommand{\glossarysection}[2][]{}% no title
\renewcommand*{\glsclearpage}{}% avoid page break before glossary
\renewenvironment{theglossary}%
{\begin{longtabu} to \linewidth {clXc}}%
{\end{longtabu}}%
% Header line
\renewcommand*{\glossaryheader}{%
% Requires booktabs
%\toprule%
\textbf{Symbol} & \textbf{Name} & \textbf{Description} & \textbf{Unit}%
\tabularnewline%
\tabularnewline%
%\midrule%
\endhead%
%\bottomrule%
\endfoot%
}%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupskip}{\tabularnewline}% What to do between groups
\renewcommand*{\glossentry}[1]{%
\glsentryitem{##1}% Entry number if required
\glstarget{##1}{\glossentrysymbol{##1}} &
%\glossentrysymbol{##1} & % Symbol
\glossentryname{##1} & % Name
\glossentrydesc{##1} & % Description
\glsentryuseri{##1}% % Unit in User1-Variable
\tabularnewline%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Own glossaries %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newglossary[slg1]{onelist}{syi1}{syg1}{Category 1 units}
\newglossary[slg2]{twolist}{syi2}{syg2}{Category 2 units}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Symbols %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------------
% Category 1
%------------------
\newglossaryentry{symb:length}{%
symbol ={$l$},%
name ={Length},%
description ={Length Description},%
user1 ={\ensuremath{\protect\si{\protect\metre}}},%
type =onelist,%
sort =length,%
}
\newglossaryentry{symb:width}{%
symbol ={$w$},%
name ={Width},%
description ={Width Description},%
user1 ={\ensuremath{\protect\si{\protect\metre}}},%
type =onelist,%
sort =length,%
}
%------------------
% Category 2
%------------------
\newglossaryentry{symb:tmat}{%
symbol ={$\mathbf{T}$},%
name ={Test},%
description ={Test description},%
user1 ={$1$},%
type =twolist,%
sort =test,%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Acronyms %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newacronym{XYZ}{XYZ}{Explanation of XYZ abbreviation\protect\glsadd{gls:XYZ}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Glossary %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newglossaryentry{gls:XYZ}{
name=Name of XYZ,
description={%
Description of XYZ
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make glossaries %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeglossaries
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{Chapter 1}
\lipsum[1-3]
\chapter{Chapter 2}
\lipsum[4-5]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Glossaries %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glsaddall
\printglossary[style=altlist,title=Glossary]
\printglossary[type=\acronymtype,style=myacronymstyle]
%Symbole ausgeben
\chapter*{List of symbols}
\addcontentsline{toc}{chapter}{List of symbols}
\setglossarysection{section}% <- added
\printglossary[type=onelist,style=mysymbolstyle,nonumberlist,title=test 1]
\printglossary[type=twolist,style=mysymbolstyle,nonumberlist,title=test 2]
\end{document}