如何使用 glossaries-extra 为缩写设置用户样式?

如何使用 glossaries-extra 为缩写设置用户样式?

我使用glossaries包创建了一个首字母缩略词列表,并制作了我自己的词汇表样式,就像在 MWE 中一样:

\documentclass{article}
\usepackage[nopostdot,nonumberlist,acronym]{glossaries}

\newglossarystyle{acronym}
{%
    \setglossarystyle{long}
    \renewenvironment{theglossary}%
    {\begin{longtable}[l]{p{0.13\textwidth}p{0.7\textwidth}}}%
        {\end{longtable}}
}

\newacronym{PNG}{PNG}          {Portable Network Graphics }
\newacronym{SVG}{SVG}          {Scalable Vector Graphics}
\newacronym{JPEG}{JPEG}        {Joint Photographic Experts Group}

\makeglossaries

\begin{document}

    \glsaddall
    \printglossary[type=acronym,style=acronym,title={}]

    First use of \gls{JPEG} and \gls{PNG}. Second use of \gls{PNG} and \gls{JPEG}.

\end{document}

在此处输入图片描述

我开始使用glossaries-extra包并尝试使用\newabbreviationstyle命令来调整我的缩写风格glossaries-extra,但失败并出现Paragraph ended before \newabbreviationstyle was complete错误:

\documentclass{article}
\usepackage[nopostdot,nonumberlist,acronym]{glossaries-extra}

\newabbreviationstyle{acronym-user}
{%
    \setglossarystyle{long}
    \renewenvironment{theglossary}%
    {\begin{longtable}[l]{p{0.13\textwidth}p{0.7\textwidth}}}%
        {\end{longtable}}
}

\setabbreviationstyle{acronym-user}

\newabbreviation{PNG}{PNG}          {Portable Network Graphics }
\newabbreviation{SVG}{SVG}        {Scalable Vector Graphics}
\newabbreviation{JPEG}{JPEG}        {Joint Photographic Experts Group}

\makeglossaries

\begin{document}

    \glsaddall
    \printglossary[type=acronym,style=acronym-user,title={}]

    First use of \gls{JPEG} and \gls{PNG}. Second use of \gls{PNG} and \gls{JPEG}.

\end{document}

如何通过glossaries-extra包达到同样的效果?

答案1

我通过\newacronym使用选项字段重新定义宏来解决了这个问题first

\documentclass{article}
\usepackage[nopostdot,nonumberlist,acronym]{glossaries-extra}

\renewcommand{\newacronym}[3]{%
    \newglossaryentry{#1}{%
        type=acronym, 
        name=#2,
        description={#3},
        first={{#3} ({#2})},
    }
}

\newglossarystyle{acronym}
{%
    \setglossarystyle{long}
    \renewenvironment{theglossary}%
    {\begin{longtable}[l]{p{0.2\textwidth}p{0.7\textwidth}}}%
        {\end{longtable}}
}


\newacronym{PNG}{PNG}          {Portable Network Graphics }
\newacronym{SVG}{SVG}        {Scalable Vector Graphics}
\newacronym{JPEG}{JPEG}        {Joint Photographic Experts Group}

\makeglossaries

\begin{document}

    \glsaddall
    \printglossary[type=acronym,style=acronym,title={}] 

    First use of \gls{JPEG} and \gls{PNG}. Second use of \gls{PNG} and \gls{JPEG}.

\end{document}

相关内容