段落样式词汇表缩写列表

段落样式词汇表缩写列表

因此我开始开发一种基于段落的首字母缩略词风格。

除了两个问题外,我有一个通用的段落”

  • 一,我还没弄清楚如何从最后一个元素中删除列表分隔标点符号
  • 第二,如果我在名为“类别”的自定义字段上使用词汇表计数属性,我根本得不到列表……

这是一个根本不产生列表的 MWE。

\documentclass{article}

\usepackage{textgreek}

    \usepackage[savewrites=true,nogroupskip,style=tree]{glossaries-extra}

    \newcommand{\acrinverse}[1]{{\acrshort{#1}}\xspace{\acrlong{#1}}}

    \newglossary[alg]{acronym}{acr}{acn}{List of Acronyms}

\makeindex
\makeglossaries

    \glsenableentrycount % enable \cgls, \cglspl, \cGls, \cGlspl
    \glssetcategoryattribute{acronym}{entrycount}{1}

    % Not using \newabbreviation so redefine \cglsformat
    % to just check for the long field.
    % http://tex.stackexchange.com/questions/319997/problems-with-glsenableentrycount-when-usepackageglossaries-extra-instead-of
    \renewcommand*{\cglsformat}[2]{%
        \ifglshaslong{#1}{\glsentrylong{#1}}{\glsentryfirst{#1}}#2%
    }

\AtEndPreamble{%
    \let\ncgls\gls
    \let\ncglspl\glspl
    \let\ncGls\Gls
    \let\ncGlspl\Glspl

    \let\gls\cgls
    \let\glspl\cglspl
    \let\Gls\cGls
    \let\Glspl\cGlspl
}
%==================================================================================================================================================================

\newglossarystyle{paragraphAcronymList}{%
    \setglossarystyle{tree}% base this style on the list style
    \renewcommand{\glspostdescription}{;}
    \renewcommand*{\glossentry}[2]{%
        \glstarget{##1}{\glossentryname{##1}}:~\space\glossentrydesc{##1}\glspostdescription\space}%
    %\space\glspostdescription\space}%
}

%==================================================================================================================================================================

\newglossaryentry{TNF}{ 
    type={acronym}, 
    category={acronym},
    sort={tumor necrosis factor},  
    name={TNF}, 
    first={tumor necrosis factor (TNF)}, 
    description={tumor necrosis factor}
}   

\glssetnoexpandfield{first}
\glssetnoexpandfield{firstpl}

\newcommand{\TNFalpha}{TNF--{\textalpha}}

\newglossaryentry{TNFalpha}{
    type={acronym},
    category={acronym},
    sort={tumor necrosis factor alpha},
    name={\TNFalpha}, 
    first={\ifglsused{TNF}{\TNFalpha}{\glsunset{TNF}tumor necrosis factor alpha~(\TNFalpha)}},
    description={tumor necrosis factor alpha}
}
\newglossaryentry{HDPE}
{ 
    type={acronym},  
    category={acronym},
    name={HDPE}, 
    short={HDPE}, 
    long={high density polyethylene}, 
    first={high density polyethylene (HDPE)}, 
    description={high density polyethylene}
}

\newglossaryentry{SHG}{%
    type={acronym},
    category={acronym},
    name={SHG},
    short={SHG},
    long={second harmonic generation},
    description={second harmonic generation},
    first={second harmonic generation (SHG)},
    sort={second harmonic generation}
}%

\newglossaryentry{SRS}{%
    type={acronym},
    category={acronym},
    name={SRS},
    short={SRS},
    long={stimulated Raman scattering},
    description={stimulated Raman scattering},
    first={stimulated Raman scattering (SRS)},
    sort={stimulated Raman scattering}
}%

\newglossaryentry{TPEF}{%
    type={acronym},
    category={acronym},
    name={TPEF},
    short={TPEF},
    long={two-photon-excited fluorescence},
    description={two-photon-excited fluorescence},
    first={two-photon-excited fluorescence (TPEF) },
    sort={two-photon-excited fluorescence}
}%


\begin{document}

    \gls{TNFalpha}  
    \gls{TNFalpha}

    \gls{TNF}
    \gls{TNF}

     \gls{HDPE} 
     \gls{HDPE} 

     \gls{TPEF}
     \gls{TPEF} 

     \gls{SHG}   
     \gls{SHG} 

     \gls{SRS} 
     \gls{SRS}

    \printglossary[type=acronym,style=paragraphAcronymList]\clearpage

\end{document} 

答案1

对于自定义词汇表样式,问题本质上是显示一个列表,其中每个项目之间都有一个分隔符,但不在第一个或最后一个条目之前或之后。为此,我们可以使用中描述的相同方法迭代技巧和窍门。 像这样:

\newglossarystyle{paragraphAcronymList}{%
    \setglossarystyle{tree}% base this style on the list style
    \def\entrysep{\def\entrysep{; }}%
    \renewenvironment{theglossary}%
    {\setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}}%
    {.}%
    \renewcommand*{\glossentry}[2]{%
        \entrysep\glstarget{##1}{\glossentryname{##1}}:~\space\glossentrydesc{##1}\glspostdescription}%
}

条目计数问题可能最好作为单独的问题发布。

相关内容