我想修改首字母缩略词的第一个显示的外观。我尝试过:
\usepackage[toc,xindy]{glossaries}
\newcommand*{\glossfirstformat}[1]{\textit{#1}}
\defglsentryfmt{\glossfirstformat{\glsgenentryfmt}} %Does work
\defglsentryfmt[\acronymtype]{\glossfirstformat{\glsgenentryfmt}} %Does not have any effect
附录:
似乎\acronymtype
只有在选项acronym
用于glossaries
包时才定义。但我只想有一个包含首字母缩略词的词汇表。我使用技巧
\usepackage{xparse}
\DeclareDocumentCommand{\newdualentry}{ O{} O{} m m m m }{
\newglossaryentry{gls-#3}{name={#5},text={#5\glsadd{#3}},description={#6},#1}
\newacronym[see={[Glossary:]{gls-#3}},#2]{#3}{#4}{#5\glsadd{gls-#3}}
}
请问这样该如何解决呢?
附录2:
当前提出的解决方案破坏了其他条目的格式规则。澄清一下我想要的:
答案1
对于首字母缩略词,你可以定义一种新的风格
\newacronymstyle{myacro}
{%
\GlsUseAcrEntryDispStyle{long-short}%
}%
{%
\GlsUseAcrStyleDefs{long-short}%
\renewcommand*{\genacrfullformat}[1]{%
\glossfirstformat{\glsentrylong{##1}}\space
(\glsentryshort{##1})%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\glossfirstformat{\Glsentrylong{##1}}\space
(\glsentryshort{##1})%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\glossfirstformat{\glsentrylongpl{##1}}\space
(\glsentryshortpl{##1})%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\glossfirstformat{\Glsentrylongpl{##1}}\space
(\glsentryshortpl{##1})%
}%
}
然后使用它
\setacronymstyle{myacro}
对于普通词汇表条目,您可以定义
\defglsentryfmt{%
\ifglshaslong{\glslabel}{%
\glsgenacfmt%
}{%
\ifglsused{\glslabel}{%
\glsgenentryfmt%
}{%
\glossfirstformat{\glsgenentryfmt}%
}%
}%
}
梅威瑟:
% arara: pdflatex: {synctex: yes}
% arara: makeglossaries
% arara: pdflatex: {synctex: yes}
% arara: pdflatex: {synctex: yes}
\documentclass{article}
\usepackage[toc]{glossaries}
\newcommand*{\glossfirstformat}[1]{\textit{#1}}
\newacronymstyle{myacro}
{%
\GlsUseAcrEntryDispStyle{long-short}%
}%
{%
\GlsUseAcrStyleDefs{long-short}%
\renewcommand*{\genacrfullformat}[1]{%
\glossfirstformat{\glsentrylong{##1}}\space
(\glsentryshort{##1})%
}%
\renewcommand*{\Genacrfullformat}[2]{%
\glossfirstformat{\Glsentrylong{##1}}\space
(\glsentryshort{##1})%
}%
\renewcommand*{\genplacrfullformat}[2]{%
\glossfirstformat{\glsentrylongpl{##1}}\space
(\glsentryshortpl{##1})%
}%
\renewcommand*{\Genplacrfullformat}[2]{%
\glossfirstformat{\Glsentrylongpl{##1}}\space
(\glsentryshortpl{##1})%
}%
}
\setacronymstyle{myacro}
\defglsentryfmt{%
\ifglshaslong{\glslabel}{%
\glsgenacfmt%
}{%
\ifglsused{\glslabel}{%
\glsgenentryfmt%
}{%
\glossfirstformat{\glsgenentryfmt}%
}%
}%
}
\makeglossaries
\newacronym{AAA}{aaa}{acronym description}
\newglossaryentry{BBB}
{
name={glossary name},
description={glossary description},
}
\begin{document}
First use of acronym: \gls{AAA}, and second use: \gls{AAA}.
First use of glossary: \gls{BBB}, and second use: \gls{BBB}.
\printglossaries
\end{document}
输出:
如果正常的词汇表条目总是以斜体排版(不仅仅是在第一次使用时),则将上述内容更改\defglsentryfmt
为
\defglsentryfmt{%
\ifglshaslong{\glslabel}{%
\glsgenacfmt%
}{%
\glossfirstformat{\glsgenentryfmt}%
}%
}