我使用词汇表包来生成我的首字母缩略词列表。由于我在文本中使用了首字母缩略词,因此我必须将描述写成小写。因此,我在首字母缩略词列表中有一个小写的描述。我可以更改该行为吗?
\documentclass[a4paper]{article}
%
\setlength{\parindent}{0pt}
%
\usepackage{xcolor}
\usepackage{hyperref}% Must now be the second-last package that is loaded
\usepackage[acronym]{glossaries}% Must be last package, loaded after hyperref
%
\newglossaryentry{htdoc}{name={hypertext document},description={Text file with references to other content via hyperlinks}}
%
\newglossaryentry{web}{name={World Wide Web},first={World Wide Web (WWW)}, text={WWW},description={A distributed system of linked hypertext documents}}
%
\newacronym{test}{Test}{Lowercase is what I want}
%
\makeglossaries
\begin{document}
% Test of glossary entries
% 1. Capitalization
Here is the acronym in the text \gls{test}
% HTML should not appear in acronym list because not cited and not added
%
\printglossaries
%
\end{document}
这就是我得到的:
答案1
类似这样的作品\printglossaries
:
\let\firstchar\lowercase
\let\oldprintglossaries\printglossaries
\def\printglossaries{\let\firstchar\uppercase\oldprintglossaries}
\newacronym{test}{Test}{\firstchar{t}his is a test}
工作示例
\documentclass[a4paper]{article}
%
\setlength{\parindent}{0pt}
%
\usepackage{xcolor}
\usepackage{hyperref}% Must now be the second-last package that is loaded
\usepackage[acronym]{glossaries}% Must be last package, loaded after hyperref
%
\newglossaryentry{htdoc}{name={hypertext document},description={Text file with references to other content via hyperlinks}}
\newglossaryentry{web}{name={World Wide Web},first={World Wide Web (WWW)}, text={WWW},description={A distributed system of linked hypertext documents}}
%
\let\firstchar\lowercase
\let\oldprintglossaries\printglossaries
\def\printglossaries{\let\firstchar\uppercase\oldprintglossaries}
\newacronym{test}{Test}{\firstchar{L}owercase is what I want}
\makeglossaries
\begin{document}
% Test of glossary entries
% 1. Capitalization
Here is the acronym in the text \gls{test}
% HTML should not appear in acronym list because not cited and not added
%
\printglossaries
%
\end{document}
NoIdx 版本
如果\printnoidxglossaries
要使用,请使用以下重新定义:
\let\firstchar\lowercase
\let\oldprintnoidxglossaries\printnoidxglossaries
\def\printnoidxglossaries{\let\firstchar\uppercase\oldprintnoidxglossaries}
答案2
您可以使用description
选项glossaries
,这可能意味着向首字母缩略词列表添加与首字母缩略词的长格式不同的描述。但这意味着,如果描述和长格式仅在第一个字母上不同,它也有效。这显然不如大卫的解决方案,因为您必须输入每个表格两次......
\documentclass[12pt]{article}
\usepackage[acronym,description]{glossaries}
\makeglossaries
\newacronym[description=This is a test]{test}{Test}{this is a test}
\newglossaryentry{web}{
name={World Wide Web},
first={World Wide Web (WWW)},
text={WWW},
description={A distributed system of linked hypertext documents}
}
\begin{document}
Here comes \gls{test}
Here comes \gls{web}
\printglossary[type=\acronymtype]
\printglossary
\end{document}
答案3
我认为您应该根据需要在文本中定义所有首字母缩略词的描述,即小写。然后,您可以重新定义词汇表样式以产生您想要的输出。如果我理解正确的话,您希望解释的第一个字母大写。这可以按如下方式实现(注意:我不太熟悉 tex 编程或 glossaries.sty 代码 - 这是我在遇到相同问题后设法做到的):
\documentclass{article}
\usepackage[hyperfirst=false,toc,acronym,nogroupskip,nomain,indexonlyfirst]{glossaries}
\newglossarystyle{csuper}{%
%do everything as in the "super" style: (cf. glossaries-user.pdf Example 22 (Creating a new glossary style based on an existing style))
\setglossarystyle{super}%
%Here, I copied the code from glossary-super.sty which defines the \glossentry command.
%Note how the original use of "\glossentrydesc" was exchanged for "\Glossentrydesc".
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
}%
%
%additionally, I usually want the glossary to be wider and to have dots similar to the table of contents:
\setlength{\glsdescwidth}{0.75\linewidth}%
\renewcommand*{\glspostdescription}{\dotfill}%
}
\setglossarystyle{csuper}
\newacronym{ccdf}{CCDF}{complementary cumulative distribution function}
\newacronym{awgn}{AWGN}{additive white Gaussian noise}
\newacronym{mer}{MER}{message error rate}
\makeglossaries
\begin{document}
Here is the acronym in the text \gls{awgn}. Bla bla blah \gls{mer}. At the Beginning of a sentence, we have to capitalize as follows. \Gls{ccdf} blah blah blah \gls{ccdf}.
Bla bla blah \gls{mer}. Blah blah blah \gls{ccdf}.
\printacronyms[title=List of Acronyms]
\end{document}
希望有所帮助。
答案4
我知道,这是一个老问题,但我设法优雅地提供了自动转换为小写的首字母缩略词描述,同时保持专有名词和缩写不变。
我定义了一个新命令\MakeLowercaseEscaped
,它将除花括号中的字符(类似于 BibLaTeX 条目中的标题)之外的所有字符转换为小写。因此,我可以提供大写的首字母缩略词描述,这些描述会自动转换为小写。缺点是,它需要 BibLaTeX,因为我借用了 BibLaTeX 的内部结构\MakeSentencecase
。
\makeatletter
\newrobustcmd{\MakeLowercaseEscaped}{%
\let\blx@mksc@endhead\relax% prevent capitalization of first character
\blx@mksc@ii}
\makeatother
之后,\newacronym
可以在文档正文中使用首字母缩略词时将描述重新定义为小写:
\let\oldnewacronym\newacronym
\renewcommand\newacronym[3]{%
\oldnewacronym[sort=#1,description=#3]{#1}{#2}{\MakeLowercaseEscaped{#3}}}
现在,可以用花括号定义首字母缩略词,以避免将专有名词和缩写小写:
\newacronym{dsl}{DSL}{Domain-Specific Language}
\newacronym{egpu}{eGPU}{Embedded {GPU}}
\newacronym{latex}{\LaTeX}{{Lamport} {TeX}}
\newacronym
使用花括号非常优雅,因为如果没有重新定义或 BibLaTeX 不可用,它们不会弄乱排版。
解决方案的 MWE:
\documentclass[12pt]{article}
\usepackage[acronym]{glossaries}
\usepackage[casechanger=latex2e]{biblatex}
\makenoidxglossaries
\makeatletter
\@ifpackageloaded{biblatex}{%
\@ifpackagewith{biblatex}{casechanger=latex2e}{}{%
% IMPORTANT: BibLaTeX must be loaded with 'casechanger=latex2e' for
% \MakeSentenceCase*{}'s internals to be available.
\@latex@error{load biblatex package with option 'casechanger=latex2e'}}
\newrobustcmd{\MakeLowercaseEscaped}{%
\let\blx@mksc@endhead\relax% prevent capitalization of first character
\blx@mksc@ii}
}{\newcommand\MakeLowercaseEscaped[1]{#1}}% fallback
\makeatother
\let\oldnewacronym\newacronym
\renewcommand\newacronym[3]{%
\oldnewacronym[sort=#1,description=#3]{#1}{#2}{\MakeLowercaseEscaped{#3}}}
\newacronym{dsl}{DSL}{Domain-Specific Language}
\newacronym{egpu}{eGPU}{Embedded {GPU}}
\newacronym{latex}{\LaTeX}{{Lamport} {TeX}}
\begin{document}
\Glspl{dsl} can be used to generate code for an \gls{egpu}.
This document was produced with the typesetting system \gls{latex}.
\printnoidxglossary[type=acronym]
\end{document}
更新
BibLaTeX 的较新版本需要选项casechanger=latex2e
可用\blx@mksc@*
。我更新了 MWE。