词汇表包条目定制。acrshort 不起作用

词汇表包条目定制。acrshort 不起作用

我已经定制了,借助如何结合缩略词和词汇表。但是,我无法获得 acrshort 或 glsentryshort 输出。

梅威瑟:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronym]{glossaries}

    % 1 -> key
    % 2 -> name
    % 3 -> pluralname
    % 4 -> long
    % 5 -> longplural
    % 6 -> description

    \newcommand*{\newdualentry}[6]{%
        %%% The glossary entry the acronym links to
        \longnewglossaryentry{{#1}g}%
        {%
            name={#2}%title of glossary entry
        }%
        {#6}%description, possibly multiparagraph
        %
        %%% define the acronym and use the see= option
        \newglossaryentry{#1}%
        {%
            type=\acronymtype,%
            name={#2},
            plural={#3},
            long={#4},
            longplural={#5},
            description={#6},
            first={#4 (#2)},
            firstplural={#5 (#3)}
            }%
    }%

    % Renew gls commands

    \let\oldgls\gls
    \let\oldGls\Gls
    \let\oldglspl\glspl
    \let\oldGlspl\Glspl
    %\let\oldacrshort\arcshort


    \renewcommand*{\gls}[1]{\oldgls{#1}\glsadd{{#1}g}}
    \renewcommand*{\Gls}[1]{\oldGls{#1}\glsadd{{#1}g}}
    \renewcommand*{\glspl}[1]{\oldglspl{#1}\glsadd{{#1}g}}
    \renewcommand*{\Glspl}[1]{\oldGlspl{#1}\glsadd{{#1}g}}
    %\renewcommand*{\acrshort}[1]{\oldacrshort{#1}g}

\makeglossaries

\newdualentry{snap}
{SNAP}
{SNAP}
{Stanford Large Network Dataset collection}
{Stanford Large Network Dataset collection}
{D}

\begin{document}

gls is working as expected. First use: \gls{snap}. Second use: \gls{snap}.

However, acrshort, acrlong, acrfull, and glsentry* variants do not work properly.
\\acrshort: \acrshort{snap}
\\acrlong: \acrlong{snap}
\\acrfull: \acrfull{snap}
\\glsentrytext: \glsentrytext{snap}
\\glsentryshort: \glsentryshort{snap}
\\glsentrylong: \glsentrylong{snap}
\\glsentryfull: \glsentryfull{snap}

\clearpage

\printglossary[type=\acronymtype]

\printglossary

\end{document}

在此处输入图片描述

答案1

您需要添加简短的定义。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronym]{glossaries}

    % 1 -> key
    % 2 -> name <---- which is also the short
    % 3 -> pluralname
    % 4 -> long
    % 5 -> longplural
    % 6 -> description

    \newcommand*{\newdualentry}[6]{%
        %%% The glossary entry the acronym links to
        \longnewglossaryentry{{#1}g}%
        {%
            name={#2}%title of glossary entry
        }%
        {#6}%description, possibly multiparagraph
        %
        %%% define the acronym and use the see= option
        \newglossaryentry{#1}%
        {%
            type=\acronymtype,%
            name={#2},
            short={#2}, % <------------------ THIS RIGHT HERE
            plural={#3},
            long={#4},
            longplural={#5},
            description={#6},
            first={#4 (#2)},
            firstplural={#5 (#3)}
            }%
    }%

    % Renew gls commands

    \let\oldgls\gls
    \let\oldGls\Gls
    \let\oldglspl\glspl
    \let\oldGlspl\Glspl
    %\let\oldacrshort\arcshort


    \renewcommand*{\gls}[1]{\oldgls{#1}\glsadd{{#1}g}}
    \renewcommand*{\Gls}[1]{\oldGls{#1}\glsadd{{#1}g}}
    \renewcommand*{\glspl}[1]{\oldglspl{#1}\glsadd{{#1}g}}
    \renewcommand*{\Glspl}[1]{\oldGlspl{#1}\glsadd{{#1}g}}
    %\renewcommand*{\acrshort}[1]{\oldacrshort{#1}g}

\makeglossaries

\newdualentry{snap}
{SNAP}
{SNAP}
{Stanford Large Network Dataset collection}
{Stanford Large Network Dataset collection}
{D}

\begin{document}

gls is working as expected. First use: \gls{snap}. Second use: \gls{snap}.

However, acrshort, acrlong, acrfull, and glsentry* variants do not work properly.
\\acrshort: \acrshort{snap}
\\acrlong: \acrlong{snap}
\\acrfull: \acrfull{snap}
\\glsentrytext: \glsentrytext{snap}
\\glsentryshort: \glsentryshort{snap}
\\glsentrylong: \glsentrylong{snap}
\\glsentryfull: \glsentryfull{snap}

\clearpage

\printglossary[type=\acronymtype]

\printglossary

\end{document}

相关内容