我需要在首字母缩略词列表中打印文本中第一次出现的首字母缩略词的页码,而不是后续出现的页码。我该如何实现?
我已经在单独的文件中定义了我的首字母缩略词。虽然在 MWE 中,我在正文中定义了两个首字母缩略词。
例如,在 MWE 中,首字母缩略词 MC 出现在第 1 页和第 3 页。我只希望第 1 页(第一次出现)出现在首字母缩略词列表中。
我还需要在首字母缩略词列表中的描述后添加单位。例如,在第二个首字母缩略词中,“键长”旁边的单位是埃,后面跟着 L 首次出现的页码。
对于所有通信,我需要添加列名:
符号……名称和单位……首次使用于页码
这些点表示空白。
数学家协会
\documentclass[12pt,a4paper]{article}
\usepackage{hyperref}
\hypersetup{
bookmarks=true, % show bookmarks bar?
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={My title}, % title
pdfauthor={Author}, % author
pdfsubject={Subject}, % subject of the document
pdfcreator={Creator}, % creator of the document
pdfproducer={Producer}, % producer of the document
pdfkeywords={keyword1} {key2} {key3}, % list of keywords
pdfnewwindow=true, % links in new window
colorlinks=true, % false: boxed links; true: colored links
linkcolor=red, % color of internal links
citecolor=blue, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=cyan % color of external links
}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{lipsum,appendix}
\usepackage[english]{babel}
%glossaries and acronym
\usepackage[nomain,acronym,xindy,toc, style=alttree,numberline,savewrites=true]{glossaries}
\renewcommand*{\glspostdescription}{}%removes dot at end
\glssetwidest{AAAAAAA}% widest name
\renewcommand*{\glsnamefont}[1]{\textmd{#1}}
\makeglossaries
\renewcommand*\appendixpagename{Nomenclature}
\renewcommand*\appendixtocname{Nomenclature}
\begin{document}
%\maketitle
\pagenumbering{alph}
\newpage
\tableofcontents
\newpage
%Acronyms
\printglossaries
\newpage
\pagenumbering{arabic}
\glsresetall
\newacronym{MC}{MC}{Monte Carlo}
\newacronym{L}{L}{bond length}
This is the first use of \gls{MC}.
\newpage
This is the first use of \gls{L}.
\newpage
This is the second use of \gls{MC}.
\newpage
This is the second use of \gls{L}.
\end{document}
以下是手册中的自定义词汇表样式
%custom glossary style
\newglossarystyle{long6col}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\begin{longtable}{lp{\glsdescwidth}cccp{\glspagelistwidth}}}%
{\end{longtable}}%
% Set the table’s header:
\renewcommand
*
{\glossaryheader}{%
\bfseries Term & \bfseries Description & \bfseries Symbol &
\bfseries Units & \bfseries Dimensions & \bfseries Page List
\\\endhead}%
% No heading between groups:
\renewcommand
*
{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
\renewcommand
*
{\glossaryentryfield}[5]{%
\glsentryitem{##1}% Entry number if required
\glstarget{##1}{##2}% Name
& ##3% Description
& ##4% Symbol
& \glsentryuseri{##1}% Units
& \glsentryuserii{##1}% Dimensions
& ##5% Page list
\\% end of row
}%
% Similarly for sub-entries (no sub-entry numbers):
\renewcommand
*
{\glossarysubentryfield}[6]{%
% ignoring first argument (sub-level)
\glstarget{##2}{##3}% Name
& ##4% Description
& ##5% Symbol
& \glsentryuseri{##2}% Units
& \glsentryuserii{##2}% Dimensions
& ##6% Page list
\\% end of row
}%
% Nothing between groups:
\renewcommand
*
{\glsgroupskip}{}%
}
%END: custom glossary style
如何从上述样式中删除 SYMBOLS 和 DIMENSION?如何定义首字母缩略词?
答案1
我怀疑这个问题两年来一直没有答案的原因是因为它实际上不止一个问题,与这个网站的工作方式不符,但需要回答或关闭才能将其从未答案列表中删除。
您已经在评论中回答了第一个问题(以及问题标题)。包选项indexonlyfirst
只会将第一个用途添加到位置列表中。
梅威瑟:
\documentclass{article}
\usepackage[nopostdot,% remove dot after description
indexonlyfirst,% only index first use
nomain,acronym,xindy,toc,numberline]{glossaries}
\makeglossaries
\newacronym{MC}{MC}{Monte Carlo}
\newacronym{L}{L}{bond length}
\begin{document}
\printglossaries
\newpage
This is the first use of \gls{MC}.
\newpage
This is the first use of \gls{L}.
\newpage
This is the second use of \gls{MC}.
\newpage
This is the second use of \gls{L}.
\end{document}
你的第二个问题(实际上应该作为一个单独的帖子)有点令人困惑。
对于所有通信,我需要添加列名:
符号……名称和单位……首次使用于页码
这些点表示空白。
这表示采用 3 列表格布局,但示例代码有 6 列。假设您将单位存储在字段中user1
,并且“符号”是指缩写形式(例如L
),“名称”是指全长形式(例如bond length
),则以下内容将产生三列样式(\AA
为简单起见,我仅将其用于 ångström 符号,但最好使用它siunitx
来处理单位):
\documentclass{article}
\usepackage[nopostdot,% remove dot after description
indexonlyfirst,% only index first use
nomain,acronym,xindy,toc,numberline]{glossaries}
\makeglossaries
\newacronym[user1={\AA}]{L}{L}{bond length}
\newglossarystyle{myunitstyle}{%
\setglossarystyle{long3col}% base it on the long3col style
\renewenvironment{theglossary}%
{\begin{longtable}{llc}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\bfseries Symbol&\bfseries Name and Units&
\bfseries First used on Page No.\tabularnewline\endhead}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glossentrydesc{##1} \glsentryuseri{##1} & ##2\tabularnewline
}%
}
\setglossarystyle{myunitstyle}
\begin{document}
\printglossaries
\newpage
This is the first use of \gls{L}.
\newpage
This is the second use of \gls{L}.
\end{document}
得出的结果为: