如何在较长的词汇表-额外名称条目中换行

如何在较长的词汇表-额外名称条目中换行

我想在词汇表条目名称中换行,如下例所示:

特别是在以下情况下换行:

likvidatsiya posledstviy primeneniya protivnikom oruzhiya %at this position% massovogo porazheniya

\documentclass{article}
\usepackage[style=altlisthypergroup]{glossaries-extra}

\newglossaryentry{likvidatsiya-posledstviy-primeneniya-protivnikom-oruzhiya-massovogo-porazheniya}{%
    name={likvidatsiya posledstviy primeneniya protivnikom oruzhiya massovogo porazheniya},%
    description={Eliminating the effects of enemy use of weapons of mass destruction (decontamination) - the aggregate of measures taken to clear up the effects of enemy use of nuclear, biological, and chemical warfare. This is done to restore, in a short period, the disrupted combat efficiency of friendly troops, and to create conditions permitting successful completion of the missions assigned to them.%
    }
}

\begin{document}
    water is good but \gls{likvidatsiya-posledstviy-primeneniya-protivnikom-oruzhiya-massovogo-porazheniya} is better
    
    \printglossaries
\end{document}

答案1

要打破条目名称行,我们需要插入一个\\

以前,条目名称必须封装在parbox基于 的新样式中,并altlisthypergroup进行定义。

(需要添加 MWE\makeglossaries才能编译)

b

b

    \documentclass{article}
\usepackage{glossaries-extra}

\makeglossaries % added <<<<<<<<<<<<<

\newglossaryentry{likvidatsiya-posledstviy-primeneniya-protivnikom-oruzhiya-massovogo-porazheniya}{%
    name={likvidatsiya posledstviy primeneniya protivnikom oruzhiya \\ massovogo porazheniya},%
    description={Eliminating the effects of enemy use of weapons of mass destruction (decontamination) - the aggregate of measures taken to clear up the effects of enemy use of nuclear, biological, and chemical warfare. This is done to restore, in a short period, the disrupted combat efficiency of friendly troops, and to create conditions permitting successful completion of the missions assigned to them.%
    } % \\ inserted 
}

\newglossarystyle{altlisthypergroup2}{% added <<<<<<<<<<<<<
    \setglossarystyle{altlisthypergroup}%
    \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}\glstarget{##1}
    {\parbox[t]{\textwidth}{\glossentryname{##1}}}] 
    \mbox{}\par\nobreak
    \glossentrydesc{##1}\glspostdescription\space ##2}%
}

\glossarystyle{altlisthypergroup2} % added <<<<<<<<<<<<<

\begin{document}

water is good but \gls{likvidatsiya-posledstviy-primeneniya-protivnikom-oruzhiya-massovogo-porazheniya} is better
    
\printglossaries
\end{document}

相关内容