对于一组符号,如何在下一页中获取列标题(描述)?

对于一组符号,如何在下一页中获取列标题(描述)?

这个问题参考了如何实现命名条目,如:符号、描述、尺寸和单位等?

我可以为不同的类别实现不同的样式。排序也按照图中所示的方式进行。 在此处输入图片描述

然而,实际情况是,如果某个类别从一页开始并延续到下一页,则标题不会出现在下一页中。如果内容不适合一页,我希望能够在下一页中显示标题。请提出一种能够在新页面中显示标题的方法。

答案1

您可以使用以下方式轻松实现此目的glossaries代替nomencl

  • 为不同类型的符号创建单独的词汇表。
  • 为您需要的任何附加字段添加键 ( dimension, unit, definition)。
  • 根据需要创建词汇表样式。我采用了预定义样式long3col-booktabslong4col-booktabs对其进行了修改。
  • 添加词汇表条目。我本地重新定义了\glsdefaulttype将许多条目放入所需词汇表中,而无需type为每个条目提供密钥。您也可以从不同的文件加载它们,或者创建自定义宏以获得同样的便利性。
  • 将所有定义的条目添加到词汇表中(这样您不必在文档中使用它们)。

提醒一下: 的完整编译周期glossariespdflatexmakeglossariespdflatexpdflatex(或等效周期)。(这是手册中的“选项 2”。)

\documentclass{article}

\usepackage[nonumberlist]{glossaries}
\usepackage{glossary-longbooktabs}
\usepackage{booktabs}
\usepackage{siunitx}

\newglossary*{nodimennum}{Dimensionless Numbers}
\newglossary*{greeksym}{Greek Symbols}

\glsaddkey{dimension}
  {--}
  {\glsentrydimension}
  {\Glsentrydimension}
  {\glsdimension}
  {\Glsdimension}
  {\GLSdimension}
\glsaddkey{unit}
  {--}
  {\glsentryunit}
  {\Glsentryunit}
  {\glsunit}
  {\Glsunit}
  {\GLSunit}
\glsaddkey{definition}
  {--}
  {\glsentrydefinition}
  {\Glsentrydefinition}
  {\glsdefinition}
  {\Glsdefinition}
  {\GLSdefinition}
\glssetnoexpandfield{dimension}
\glssetnoexpandfield{unit}

\newcommand*\dimensionname{Dimension}
\newcommand*\unitname{Unit}
\newcommand*\definitionname{Definition}

\newglossarystyle{nodimennum}{%
  \glspatchLToutput
  \renewenvironment{theglossary}%
    {\begin{longtable}{l p{.35\linewidth} p{.35\linewidth}}}%
    {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \toprule
    \bfseries \symbolname &
    \bfseries \descriptionname &
    \bfseries \definitionname
    \tabularnewline\midrule\endhead
    \bottomrule\endfoot}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentrysymbol{##1}} &
    \glossentrydesc{##1} &
    \glsentrydefinition{##1} \tabularnewline
  }%
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{\glspenaltygroupskip}%
  \fi
}
\newglossarystyle{physsym}{%
  \glspatchLToutput
  \renewenvironment{theglossary}%
    {\begin{longtable}{l l l l}}%
    {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \toprule \bfseries \symbolname &
    \bfseries \descriptionname &
    \bfseries \dimensionname &
    \bfseries \unitname
    \tabularnewline\midrule\endhead
    \bottomrule\endfoot}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentrysymbol{##1}} &
    \glossentrydesc{##1} &
    \glsentrydimension{##1} &
    \glsentryunit{##1} \tabularnewline
  }%
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{\glspenaltygroupskip}%
  \fi
}

\begingroup\renewcommand*\glsdefaulttype{greeksym}
  \newglossaryentry{eps0}{
    name={eps0},
    symbol={\(\varepsilon_0\)},
    description={vacuum permittivity},
    dimension={\(\mathrm F / \mathrm L\)},
    unit={\si{\farad\per\meter}},
  }
\endgroup

\begingroup\renewcommand*\glsdefaulttype{nodimennum}
  \newglossaryentry{zero}{
    name={0},
    symbol={\(0\)},
    description={zero},
    definition={the smallest natural number},
  }
  \newglossaryentry{one}{
    name={1},
    symbol={\(1\)},
    description={one},
    definition={\(0 + 1\)},
  }
  \newglossaryentry{two}{
    name={1},
    symbol={\(2\)},
    description={two},
    definition={\(1 + 1\)},
  }
  \newglossaryentry{three}{
    name={3},
    symbol={\(3\)},
    description={three},
    definition={\(2 + 1\)},
  }
  \newglossaryentry{four}{
    name={4},
    symbol={\(4\)},
    description={four},
    definition={\(3 + 1\)},
  }
  \newglossaryentry{five}{
    name={5},
    symbol={\(5\)},
    description={five},
    definition={\(4 + 1\)},
  }
  \newglossaryentry{six}{
    name={6},
    symbol={\(6\)},
    description={six},
    definition={\(5 + 1\)},
  }
  \newglossaryentry{seven}{
    name={7},
    symbol={\(7\)},
    description={seven},
    definition={\(6 + 1\)},
  }
  \newglossaryentry{eight}{
    name={8},
    symbol={\(8\)},
    description={eight},
    definition={\(7 + 1\)},
  }
  \newglossaryentry{nine}{
    name={9},
    symbol={\(9\)},
    description={nine},
    definition={\(8 + 1\)},
  }
\endgroup

\makeglossaries
\glsaddall

\begin{document}

Hello World!
\vskip .6\textheight

\printglossary[type=greeksym, style=physsym]
\printglossary[type=nodimennum, style=nodimennum]

\end{document}

MWE 输出

答案2

这是我的答案。感谢@schtandard。我稍微修改了他的代码,并能够得到更接近我需要的东西。

\documentclass[12pt,a4paper]{article}
\usepackage[inner=1in,outer=1in,tmargin=1in,bmargin=1in]{geometry}
\usepackage{tabu}
\usepackage[nonumberlist, automake]{glossaries}
\usepackage{glossary-longbooktabs}
\usepackage{booktabs}
\usepackage{siunitx}
\newglossary*{nodimennum}{Dimensionless Numbers}
\newglossary*{greeksym}{Greek Symbols}

\glsaddkey{dimension}
  {--}
  {\glsentrydimension}
  {\Glsentrydimension}
  {\glsdimension}
  {\Glsdimension}
  {\GLSdimension}
\glsaddkey{unit}
  {--}
  {\glsentryunit}
  {\Glsentryunit}
  {\glsunit}
  {\Glsunit}
  {\GLSunit}
\glsaddkey{definition}
  {--}
  {\glsentrydefinition}
  {\Glsentrydefinition}
  {\glsdefinition}
  {\Glsdefinition}
  {\GLSdefinition}
\glssetnoexpandfield{dimension}
\glssetnoexpandfield{unit}

\newcommand*\dimensionname{Dimension}
\newcommand*\unitname{Unit}
\newcommand*\definitionname{Definition}

\newglossarystyle{nodimennum}{%
  \glspatchLToutput
  \renewenvironment{theglossary}%
    %{\begin{center}\begin{longtable}{@{\extracolsep{\fill}}p{.2\linewidth}p{.35\linewidth}p{.35\linewidth}}}%
    {\begin{longtabu}{lXX}}%
    {\end{longtabu}}%
    %{\end{longtable}\end{center}}%
  \renewcommand*{\glossaryheader}{%
    \toprule
    \bfseries \symbolname &
    \bfseries \descriptionname &
    \bfseries \definitionname
    \tabularnewline\midrule\endhead
    \bottomrule\endfoot}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentrysymbol{##1}} &
    \glossentrydesc{##1} &
    \glsentrydefinition{##1} \tabularnewline
  }%
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{\glspenaltygroupskip}%
  \fi
}
\newglossarystyle{physsym}{%
  \glspatchLToutput
  \renewenvironment{theglossary}%
    %{\begin{center}\begin{longtable}{@{\extracolsep{\fill}} l l l l}}%
    {\begin{longtabu}{l X X X}}%
    {\end{longtabu}}%
    %{\end{longtable}\end{center}}%
  \renewcommand*{\glossaryheader}{%
    \toprule \bfseries \symbolname &
    \bfseries \descriptionname &
    \bfseries \dimensionname &
    \bfseries \unitname
    \tabularnewline\midrule\endhead
    \bottomrule\endfoot}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentrysymbol{##1}} &
    \glossentrydesc{##1} &
    \glsentrydimension{##1} &
    \glsentryunit{##1} \tabularnewline
  }%
  \ifglsnogroupskip
    \renewcommand*{\glsgroupskip}{}%
  \else
    \renewcommand*{\glsgroupskip}{\glspenaltygroupskip}%
  \fi
}
\makeglossaries
\begingroup\renewcommand*\glsdefaulttype{greeksym}
  \newglossaryentry{eps0}{
    name={eps0},
    symbol={\(\varepsilon_0\)},
    description={vacuum permittivity},
    dimension={\(\mathrm F / \mathrm L\)},
    unit={\si{\farad\per\meter}},
  }
\endgroup

\begingroup\renewcommand*\glsdefaulttype{nodimennum}
  \newglossaryentry{zero}{
    name={0},
    symbol={\(0\)},
    description={zero},
    definition={the smallest natural number},
  }
  \newglossaryentry{one}{
    name={1},
    symbol={\(1\)},
    description={one},
    definition={\(0 + 1\)},
  }
  \newglossaryentry{two}{
    name={1},
    symbol={\(2\)},
    description={two},
    definition={\(1 + 1\)},
  }
  \newglossaryentry{three}{
    name={3},
    symbol={\(3\)},
    description={three},
    definition={\(2 + 1\)},
  }
  \newglossaryentry{four}{
    name={4},
    symbol={\(4\)},
    description={four},
    definition={\(3 + 1\)},
  }
  \newglossaryentry{five}{
    name={5},
    symbol={\(5\)},
    description={five},
    definition={\(4 + 1\)},
  }
  \newglossaryentry{six}{
    name={6},
    symbol={\(6\)},
    description={six},
    definition={\(5 + 1\)},
  }
  \newglossaryentry{seven}{
    name={7},
    symbol={\(7\)},
    description={seven},
    definition={\(6 + 1\)},
  }
  \newglossaryentry{eight}{
    name={8},
    symbol={\(8\)},
    description={eight},
    definition={\(7 + 1\)},
  }
  \newglossaryentry{nine}{
    name={9},
    symbol={\(9\)},
    description={nine},
    definition={\(8 + 1\)},
  }
\endgroup

%\makeglossaries
\glsaddall

\begin{document}

Hello World!
\vskip .6\textheight

\printglossary[type=greeksym, style=physsym]
\printglossary[type=nodimennum, style=nodimennum]

\end{document}

相关内容