在词汇表符号列表中使用粗体和非粗体符号

在词汇表符号列表中使用粗体和非粗体符号

我正在使用词汇表来创建首字母缩略词和符号列表。对于包括单位在内的符号列表,我使用了 Christian Hupfer 的这个答案中的代码:词汇表:如何自定义带有单位附加列的符号列表?

但是,我需要区分粗体和非粗体符号(指张量或标量),这显然无法用该代码实现。我在代码调整方面遇到了很大困难,但找不到任何方法来实现这一点。有人能帮我吗?非常感谢!!

梅威瑟:

\documentclass{book}                           
\usepackage{siunitx}
\usepackage[acronym,toc]{glossaries}              % use glossaries-package


\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{sig}{name=\ensuremath{\sigma},
    description={This is a non-bold stress scalar},
    unit={\si{\mega\pascal}},
    type=symbolslist}

\newglossaryentry{csig}{name=\ensuremath{\boldsymbol{\sigma}},
    description={This is a bold Cauchy stress tensor},
    unit={\si{\mega\pascal}},
    type=symbolslist}


% ==== EXEMPLARY ENTRY FOR ACRONYMS LIST     ========================================
\newacronym{frp}{FRP}{Fiber Reinforced Polymers}


\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
  \begin{longtable}{lp{0.6\glsdescwidth}>{\centeringarraybackslash}p{2cm}}}%
  {\end{longtable}}%
%
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Sign & \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]   % list of     symbols

\end{document}

答案1

您的示例编译时会出现错误。在词汇表条目中使用 siunitx 命令时,您应该使用或禁用词汇表字段的扩展\glsnoexpandfields(不推荐,因为它有其他问题)将定义移到 \begin{document} 后面,因为 siunitx 只进行了大量初始化\begin{document}。除此之外,您还有拼写错误(缺少反斜杠)。如果我更正错误,粗体符号就可以正常工作:

\documentclass{book}
\usepackage{siunitx}

\usepackage[acronym,toc]{glossaries}              % use glossaries-package


\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 ACRONYMS LIST     ========================================
\newacronym{frp}{FRP}{Fiber Reinforced Polymers}


\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
  \begin{longtable}{lp{0.6\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
  {\end{longtable}}%
%
\renewcommand*{\glossaryheader}{%  Change the table header
  \bfseries Sign & \bfseries Description & \bfseries Unit \\
  \hline
  \endhead}
\renewcommand*{\glossentry}[2]{%  Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsunit{##1}  \tabularnewline
}
}
\glsnoexpandfields
% ==== EXEMPLARY ENTRY FOR SYMBOLS LIST =========================================


\newglossaryentry{sig}{name=\ensuremath{\sigma},
    description={This is a non-bold stress scalar},
    unit={\si{\mega\pascal}},
    type=symbolslist}

\newglossaryentry{csig}{name=\ensuremath{\boldsymbol{\sigma}},
    description={This is a bold Cauchy stress tensor},
    unit={\si{\mega\pascal}},
    type=symbolslist}

    \begin{document}
    \glsaddall

    \printglossary[type=\acronymtype,style=long]  % list of acronyms
    \printglossary[type=symbolslist,style=symbunitlong]   % list of     symbols

\end{document}

在此处输入图片描述

相关内容