我正在使用给出的解决方案这里使用包在页边空白处显示缩写的长版本glossaries
。效果很好,但我希望它只对某个组织的缩写起作用,而不对其他组织起作用。
这是 MWE
\documentclass[chapterprefix,twoside,12pt,DIV=12]{scrbook}
\KOMAoptions{headsepline=true, chapterprefix=true}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[onehalfspacing]{setspace}
\usepackage[bottom]{footmisc}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{etoolbox}
\usepackage[acronym,smallcaps]{glossaries}
\makeglossaries
\makeatletter
\defglsentryfmt[acronym]{\glsgenacfmt
\ifglsused{\glslabel}{\if@mainmatter
\expandafter\ifx\csname mhused\glslabel\endcsname\relax
\expandafter\gdef\csname mhused\glslabel\endcsname{}%
\xappto\mhclearacrmargin{\global\expandafter\expandafter\expandafter\let\expandafter\noexpand\csname mhused\glslabel\endcsname\relax}\marginpar{{\scriptsize
\textsf{\glsentrylong{\glslabel}}}}\fi\fi}{}}
\patchcmd\@outputpage{\botmark}{\botmark \mhclearacrmargin \gdef\mhclearacrmargin{}}{}{}{}
\makeatother
\newcommand{\mhacrshort}[1]{\acronymfont{\glsentryshort{#1}}}
\newcommand{\mhacrlong}[1]{\glsentrylong{#1}}
\newcommand{\mhclearacrmargin}{}
\newacronym{unesco}{unesco}{United Nations Educational, Scientific and Cultural Organization}
\newacronym{onu}{onu}{Organisation des Nations Unies}
\begin{document}
\frontmatter
\mainmatter
\chapter{test}
\section{test}
\gls{unesco} ...... \gls{onu}
\gls{onu} ... \gls{unesco}
\gls{onu} ... \gls{unesco}
\newpage
\gls{unesco} ...... \gls{onu}
\gls{onu} ... \gls{unesco}
\gls{onu} ... \gls{unesco}
\begin{table}[p]
\begin{tabular}{@{}rcl@{}}
\toprule
\textbf{Colonne 1} & \textbf{Colonne 2} & \textbf{Colonne 3} \\
\midrule
\mhacrlong{onu} & 1 & \mhacrshort{unesco} \\
\mhacrshort{onu} & 4 & \mhacrshort{unesco} \\
\bottomrule
\end{tabular}
\end{table}
\appendix
\backmatter
\gls{unesco}
\printglossary[type=acronym, style=long]\label{listofacronyms}
\end{document}
我想我们可以使用该type
选项来分离两类首字母缩略词(组织和其他),但我不知道接下来该怎么做。
答案1
有关解释请参见初始问题下方的评论对话框。
\documentclass[chapterprefix,twoside,12pt,DIV=12]{scrbook}
\KOMAoptions{headsepline=true, chapterprefix=true}
\usepackage[french]{babel}
\usepackage[onehalfspacing]{setspace}
\usepackage[acronym]{glossaries-extra}
\setabbreviationstyle{long-short-sc}
\makeglossaries
\makeatletter
\defglsentryfmt[acronym]{\glsgenacfmt
\ifglsused{\glslabel}{\if@mainmatter
\expandafter\ifx\csname mhused\glslabel\endcsname\relax
\expandafter\gdef\csname mhused\glslabel\endcsname{}%
\xappto\mhclearacrmargin{\global\expandafter\expandafter\expandafter\let\expandafter\noexpand\csname mhused\glslabel\endcsname\relax}\marginpar{{\scriptsize
\textsf{\glsifcategory{\glslabel}{show}{\glsentrylong{\glslabel}}{} }}}\fi\fi}{}}
\patchcmd\@outputpage{\botmark}{\botmark \mhclearacrmargin \gdef\mhclearacrmargin{}}{}{}{}
\makeatother
\newcommand{\mhacrshort}[1]{\acronymfont{\glsentryshort{#1}}}
\newcommand{\mhacrlong}[1]{\glsentrylong{#1}}
\newcommand{\mhclearacrmargin}{}
\newacronym[category=show]{unesco}{unesco}{United Nations Educational, Scientific and Cultural Organization}
\newacronym[category=shownot]{onu}{onu}{Organisation des Nations Unies}
\begin{document}
\chapter{test}
\gls{unesco} ...... \gls{onu}
\newpage
\gls{unesco} ...... \gls{onu}
\printglossary[type=acronym, style=long]\label{listofacronyms}
\end{document}