对于我的论文,审阅者建议我在每个方程式下方添加一个符号列表。
基于具有不同风格的多个词汇表我想到了这个:
\documentclass[12pt,twoside,booktabs,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[acronym,toc,shortcuts]{glossaries}
\usepackage{amsmath}
\newglossary[ch1]{formel}{ch2}{ch3}{Symbols}
\makenoidxglossaries
\setacronymstyle{long-short}
\newglossarystyle{formel_altlong4colheader}{%
\setglossarystyle{altlong4colheader}%
%
\renewcommand*{\glossaryheader}{%
\bfseries Symbol
& \bfseries Description
& \bfseries Unit\\
\hline
\\\endhead}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}}%
& \glossentrydesc{##1}%
& \glossentrysymbol{##1}%
\tabularnewline % end of row
}%
}
\setlength{\glsdescwidth}{3in}
\include{glossar}
\newcommand{\glsfull}[1]{%
%\glstarget{#1} %don't know what this would be for.
\glossentryname{#1}\quad : \quad%
\glossentrydesc{#1}\quad[\glossentrysymbol{#1}]
}
\newcommand{\glsfullA}[1]%
{& \glossentryname{#1} & \glossentrydesc{#1} & [\glossentrysymbol{#1}]%
}
%-----Formel---
\newglossaryentry{CDDLimit}
{%
name={$CDD_{Limit}$},
description={Cooling Degree Day Limit},
symbol={$-$},
sort=abc,
type=formel
}
\newglossaryentry{CDD}
{%
name={$CDD$},
description={Cooling Degree Day},
symbol={$\frac{W}{kg K}$},
sort=abc,
type=formel
}
\begin{document}
\printnoidxglossary[type=formel, style=formel_altlong4colheader]
\newpage
\begin{equation}
CDD_{Limit} = Max(CDD)
\end{equation}
with \\
\glsfull{CDDLimit}\\
\glsfull{CDD}\\
This is not quite what I want. I rather would like something that alligns itself like alignat*
%\begin{alignat*}{4}
% \text{with}\quad \glsfullA{CDDLimit}
% \glsfullA{CDD}
%\end{alignat*}
\end{document}
但是,如果删除最后四行中的“%”,则会出现错误。
对于问题可能出在哪里,您有何建议?
最后,希望得到如下所示的内容以及完整的符号列表。
答案1
与其单独排版每个词汇表条目,不如将词汇表关键字列表提供给宏,让宏处理所有事情,这样效率更高。电子工具箱包含一些用于处理“逗号分隔变量”的出色工具,例如\docsvlist
,可用于生成tabular
包含词汇表项的环境。该\docsvlist
命令循环遍历给定的列表并执行命令\do
,因此要使其工作,您只需重新定义\do
以便它生成一行tabular
环境。
将其包装成\GlsList
命令,然后您可以将其放在 \GlsList{CDDLimit,CDD}
方程式后面以生成
以下是完整的 MWE:
\documentclass[12pt,twoside,booktabs,a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[acronym,toc,shortcuts]{glossaries}
\usepackage{amsmath}
\newglossary[ch1]{formel}{ch2}{ch3}{Symbols}
\makenoidxglossaries
\setacronymstyle{long-short}
\newglossarystyle{formel_altlong4colheader}{%
\setglossarystyle{altlong4colheader}%
%
\renewcommand*{\glossaryheader}{%
\bfseries Symbol
& \bfseries Description
& \bfseries Unit\\
\hline
\\\endhead}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}}%
& \glossentrydesc{##1}%
& \glossentrysymbol{##1}%
\tabularnewline % end of row
}%
}
\setlength{\glsdescwidth}{3in}
\include{glossar}
\usepackage{etoolbox}
\newcommand\GlsList[1]{% generate list of glossary entries
\def\gswith{with}% for inserting "with" on the first line
\renewcommand*{\do}[1]{%
\glsadd{##1}% add glossary entry to index
\gswith&\glossentryname{##1}:&\glossentrydesc{##1}&[\glossentrysymbol{##1}]\\%
\global\let\gswith\relax% reset "with" for later lines
}
\begin{tabular}{@{}llll}
\docsvlist{#1}
\end{tabular}
}
%-----Formel---
\newglossaryentry{CDDLimit}
{%
name={$CDD_{Limit}$},
description={Cooling Degree Day Limit},
symbol={$-$},
sort=abc,
type=formel
}
\newglossaryentry{CDD}
{%
name={$CDD$},
description={Cooling Degree Day},
symbol={$\frac{W}{kg K}$},
sort=abc,
type=formel
}
\begin{document}
\printnoidxglossary[type=formel, style=formel_altlong4colheader]
\begin{equation}
CDD_{Limit} = Max(CDD)
\end{equation}
\GlsList{CDDLimit,CDD}
\end{document}
正如所宣传的那样\do
,该命令在 内部定义\GlsList
,只写入一行tabular
环境。一个隐秘之处是使用 ,\gswith
它将“with”添加到环境的第一行,之后将其设置为,\relax
这样它什么也不做。
您可能需要调整表格环境的间距和的位置:
,但这应该很简单。