![如何在较长的词汇表-额外名称条目中换行](https://linux22.com/image/432444/%E5%A6%82%E4%BD%95%E5%9C%A8%E8%BE%83%E9%95%BF%E7%9A%84%E8%AF%8D%E6%B1%87%E8%A1%A8-%E9%A2%9D%E5%A4%96%E5%90%8D%E7%A7%B0%E6%9D%A1%E7%9B%AE%E4%B8%AD%E6%8D%A2%E8%A1%8C.png)
我想在词汇表条目名称中换行,如下例所示:
特别是在以下情况下换行:
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
才能编译)
后
\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}