我有一个可能很奇怪的要求。
通常在nomenclature
使用glossaries
包时,符号是第一次使用后唯一打印的内容,但我需要相反的内容。第一次使用后,只应打印符号定义,而不是符号。
例子:
我定义了以下术语
\newacronym[user1={--}]{a}{\textit{a}}{lattice constant}
现在,当我像 一样使用它时\gls{a}
,它会lattice constant (a)
在第一次使用时像 一样展开,并且在第一次使用之后,它只会打印a
。我想要相反的。我希望lattice constant
在第一次使用之后打印并抑制a
。
因为这些符号在方程式和文本中使用,所以我需要说明符号是什么(是的,我有一个单独的命名法列表,但我需要在文本中解释一次符号)。现在,偶尔,我必须对不同的变量使用相同的符号,因此在文本中像通常的命名法一样使用符号会造成混淆,所以我需要使用完整形式。
是否可以?
平均能量损失
\documentclass[12pt,a4paper]{report}
\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
anchorcolor=green
}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[english]{babel}
\usepackage[round]{natbib}
%glossaries and acronym
\usepackage[acronym,xindy,sort=def,toc,numberline,indexonlyfirst,nomain]{glossaries} %nomain, if you define glossaries in a file, and you use \include{INP-00-glossary}
\newglossary[nlg]{nomenc}{not}{ntn}{Nomenclature}
\newglossary[slg]{abbrev}{sot}{stn}{Abbreviations}
%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 Symbol & \bfseries Description & &
\bfseries Units & & \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
%custom glossary1 style
\newglossarystyle{long6col1}{%
% 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 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}{}%
}
%
\let\oldgls\gls
\renewcommand{\gls}[1]{%
\ifglsused{#1}%
{\glsentrylong{#1}}%
{\oldgls{#1}}%
}
%END: custom glossary style
\renewcommand*{\glspostdescription}{}%removes dot at end
\glssetwidest{AAAAAAA}% widest name
\renewcommand*{\glsnamefont}[1]{\textmd{#1}}
\makeglossaries
%\loadglsentries[nomenc]{INP-00-glossary}
\let\oldacronymtype\acronymtype
\def\acronymtype{nomenc}
\loadglsentries[nomenc]{INP-00-glossary}
\let\acronymtype\oldacronymtype
\loadglsentries[abbrev]{INP-01-glossary}
\begin{document}
\printglossary[style=long6col,type=nomenc]
\newpage
\printglossary[style=long6col1,type=abbrev]
\newpage
The first use of glossary \gls{MC}.
The second use of glossary \gls{MC}.
The first use of nomenclature \gls{a}.
The second use of nomenclature \gls{a}.
\end{document}
命名法在文件中定义INP-00-glossary
\newacronym[user1={$\AA$}]{a}{\textit{a}}{lattice constant}
缩写在文件中定义INP-01-glossary
\newglossaryentry{MC}
{
name={MC},
description={Monte Carlo},
first={\glsentrydesc{MC} (\glsentrytext{MC})}
}
进一步要求:
3) 至 7) 等功能将是一个很好的补充。图片仅用于描述新请求。进一步的请求是先前功能的扩展(即,仅打印定义,而不是符号,第二次使用后,仅适用于命名法,不适用于词汇表)。
1) The first use of nomenclature \gls{a}.
2) The second use of nomenclature \gls{a}.
3) The third use of nomenclature, plural \glspl{a}.
4) The fourth use of nomenclature, uppercase \GLS{a}.
5) The fifth use of nomenclature, reset definition \glsreset{a}\gls{a}.
6) The sixth use of nomenclature, first letter capital \glsreset{a}\Gls{a}.
7) The seventh use of nomenclature, all capital letters \glsreset{a}\GLS{a}.
答案1
您可以\gls
用这种方式重新定义命令
\let\oldgls\gls
\renewcommand{\gls}[1]{%
\ifglsused{#1}%
{\glsentrylong{#1}}%
{\oldgls{#1}}%
}
因此,以下 MWE
% arara: pdflatex: {synctex: yes}
% arara: makeglossaries
% arara: pdflatex: {synctex: yes}
% arara: pdflatex: {synctex: yes}
\documentclass{article}
\usepackage[acronym]{glossaries}
\renewcommand{\acronymname}{Nomenclature}
\let\oldgls\gls
\renewcommand{\gls}[1]{%
\ifglsused{#1}%
{\glsentrylong{#1}}%
{\oldgls{#1}}%
}
\newacronym[user1={--}]{a}{\textit{a}}{lattice constant}
\makeglossaries
\begin{document}
\noindent First use: \gls{a}, and second use: \gls{a}.
\printglossaries
\end{document}
给出
编辑
您的要求可以实现,但由于\gls
无法区分该项目是来自命名法还是来自其他项目,因此您必须使用\ac
而不是\gls
命名法项目。
首先,你要shortcuts
在加载时添加选项glossaries
,也就是
\usepackage[shortcuts,acronym,xindy,sort=def,toc,numberline,indexonlyfirst,nomain]{glossaries}
然后将答案第一部分的代码替换为
\let\oldac\ac
\renewcommand{\ac}[1]{%
\ifglsused{#1}%
{\glsdesc{#1}}%
{\oldac{#1}}%
}
此时替换\gls{a}
为\ac{a}
。
结果是:
最终编辑
为了实现您所有的最新请求,我们必须深入破解glossaries.sty
代码......
忘记我们之前提到过的所有事情。
首先我们定义一个新的命令
\def\myacro{nomenc}
如果您更改了命名法的名称,则必须更改nomenc
为新名称。
然后在序言中添加以下所有代码
\makeatletter
\def\@gls@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydesc{#2}\else\glsentrytext{#2}\fi}%
{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}
}%
{%
\@gls@link[#1,hyper=false]{#2}{\@glo@text}%
}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@Gls@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\def\glslabel{#2}%
\ifglsused{#2}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydesc{#2}\else\glsentrytext{#2}\fi}%
{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@GLS@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydesc{#2}\else\glsentrytext{#2}\fi}%
{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}%
}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}%
}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}}{%
\@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@glspl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydescplural{#2}\else\glsentryplural{#2}\fi}%
{\glsentrydescplural{#2}}{\glsentrysymbolplural{#2}}{#3}}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
{\glsentrysymbolplural{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{\@glo@text}%
}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@Glspl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\def\glslabel{#2}%
\ifglsused{#2}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydescplural{#2}\else\glsentryplural{#2}\fi}%
{\glsentrydescplural{#2}}{\glsentrysymbolplural{#2}}{#3}}%
}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
{\glsentrysymbolplural{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@GLSpl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydescplural{#2}\else\glsentryplural{#2}\fi}%
{\glsentrydescplural{#2}}{\glsentrysymbolplural{#2}}{#3}%
}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
{\glsentrysymbolplural{#2}}{#3}%
}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\makeatother
最终的 MWE(我还添加了sanitize=none
允许在字段内使用 TeX 命令的选项)
\documentclass[12pt,a4paper]{report}
\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
anchorcolor=green
}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[english]{babel}
\usepackage[round]{natbib}
%glossaries and acronym
\usepackage[acronym,xindy,sanitize=none,sort=def,toc,numberline,indexonlyfirst,nomain]{glossaries} %nomain, if you define glossaries in a file, and you use \include{INP-00-glossary}
\newglossary[nlg]{nomenc}{not}{ntn}{Nomenclature}
\newglossary[slg]{abbrev}{sot}{stn}{Abbreviations}
%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 Symbol & \bfseries Description & &
\bfseries Units & & \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
%custom glossary1 style
\newglossarystyle{long6col1}{%
% 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 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}{}%
}
%-------------------------------------------------------
\def\myacro{nomenc}
\makeatletter
\def\@gls@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydesc{#2}\else\glsentrytext{#2}\fi}%
{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}
}%
{%
\@gls@link[#1,hyper=false]{#2}{\@glo@text}%
}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@Gls@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\def\glslabel{#2}%
\ifglsused{#2}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydesc{#2}\else\glsentrytext{#2}\fi}%
{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@GLS@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydesc{#2}\else\glsentrytext{#2}\fi}%
{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}%
}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}%
}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}}{%
\@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@glspl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydescplural{#2}\else\glsentryplural{#2}\fi}%
{\glsentrydescplural{#2}}{\glsentrysymbolplural{#2}}{#3}}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
{\glsentrysymbolplural{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{\@glo@text}%
}%
{%
\@gls@link[#1]{#2}{\@glo@text}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@Glspl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\def\glslabel{#2}%
\ifglsused{#2}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydescplural{#2}\else\glsentryplural{#2}\fi}%
{\glsentrydescplural{#2}}{\glsentrysymbolplural{#2}}{#3}}%
}%
{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
{\glsentrysymbolplural{#2}}{#3}}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{%
\expandafter\makefirstuc\expandafter{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\def\@GLSpl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\edef\@glo@type{\glsentrytype{#2}}%
\def\@gls@link@opts{#1}%
\def\@gls@link@label{#2}%
\ifglsused{#2}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\ifx\@glo@type\myacro\glsentrydescplural{#2}\else\glsentryplural{#2}\fi}%
{\glsentrydescplural{#2}}{\glsentrysymbolplural{#2}}{#3}%
}%
}%
{%
\def\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
{\glsentrysymbolplural{#2}}{#3}%
}%
}%
\ifglsused{#2}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\gls@checkisacronymlist\@glo@type
\ifthenelse
{%
\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
\OR \NOT\boolean{glshyperfirst}%
}%
{%
\@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
}%
{%
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
}%
}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
}
\makeatother
%-------------------------------------------------------
%END: custom glossary style
\renewcommand*{\glspostdescription}{}%removes dot at end
\glssetwidest{AAAAAAA}% widest name
\renewcommand*{\glsnamefont}[1]{\textmd{#1}}
\makeglossaries
%\loadglsentries[nomenc]{INP-00-glossary}
\let\oldacronymtype\acronymtype
\def\acronymtype{nomenc}
\loadglsentries[nomenc]{INP-00-glossary}
\let\acronymtype\oldacronymtype
\loadglsentries[abbrev]{INP-01-glossary}
\begin{document}
\printglossary[style=long6col,type=nomenc]
\newpage
\printglossary[style=long6col1,type=abbrev]
\newpage
The 1st use of glossary \gls{MC}.
The 2nd use of glossary \gls{MC}.
The 1st use of nomenclature \gls{a}.
The 2nd use of nomenclature \gls{a}.
The 3rd use of nomenclature, first letter capital \Gls{a}.
The 4th use of nomenclature, all capital letters \GLS{a}.
The 5rd use of nomenclature, plural \glspl{a}.
The 6th use of nomenclature, first letter capital plural \Glspl{a}.
The 7th use of nomenclature, all capital letters plural \GLSpl{a}.
The 8th use of nomenclature, reset definition \glsreset{a}\gls{a}.
The 9th use of nomenclature, first letter capital \glsreset{a}\Gls{a}.
The 10th use of nomenclature, all capital letters \glsreset{a}\GLS{a}.
\end{document}
结果:
答案2
这是使用 的替代解决方案glossaries-extra
,它扩展了glossaries
包。它的优点是,通过为每种缩写类型分配不同的类别,它可以在同一文档中提供多种缩写样式。
例子:
\documentclass{article}
\usepackage{glossaries-extra}
\makeglossaries
% Define a new abbreviation style called "symbolabbrv":
\newabbreviationstyle
{symbolabbrv}% style name
{% setup
\renewcommand*{\CustomAbbreviationFields}{%
name={\protect\glsabbrvfont{\the\glsshorttok}},% name just the "short" part
sort={\the\glsshorttok},% sort on the "short" part
first={\the\glslongtok\glsxtrfullsep{\glslabel}(\protect\glsabbrvfont{\the\glsshorttok})},
firstplural={\the\glslongpltok\glsxtrfullsep{\glslabel}(\protect\glsabbrvfont{\the\glsshortpltok})},
text={\the\glslongtok},
plural={\the\glslongpltok},
description={\the\glslongtok}% description is the "long" part
}%
% Treat this type of abbreviation as a regular term
\renewcommand*{\GlsXtrPostNewAbbreviation}{%
\glssetattribute{\the\glslabeltok}{regular}{true}%
}%
}%
{%
\renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
\renewcommand*{\glsabbrvfont}[1]{\textit{##1}}%
% Full form for this style:
\renewcommand*{\glsxtrfullformat}[2]{%
\glsfirstlongfont{\glsaccesslong{##1}}##2\glsxtrfullsep{##1}%
(\glsfirstabbrvfont{\glsaccessshort{##1}})%
}%
\renewcommand*{\glsxtrfullplformat}[2]{%
\glsfirstlongfont{\glsaccesslongpl{##1}}##2\glsxtrfullsep{##1}%
(\glsfirstabbrvfont{\glsaccessshortpl{##1}})%
}%
\renewcommand*{\Glsxtrfullformat}[2]{%
\glsfirstlongfont{\Glsaccesslong{##1}}##2\glsxtrfullsep{##1}%
(\glsfirstabbrvfont{\glsaccessshort{##1}})%
}%
\renewcommand*{\Glsxtrfullplformat}[2]{%
\glsfirstlongfont{\Glsaccesslongpl{##1}}##2\glsxtrfullsep{##1}%
(\glsfirstabbrvfont{\glsaccessshortpl{##1}})%
}%
}
% Set style for regular abbreviations:
\setabbreviationstyle{long-short}
% Set style for abbreviations with the category set to "symbol"
\setabbreviationstyle[symbol]{symbolabbrv}
% Define abbreviations:
\newabbreviation{mc}{MC}{Monte Carlo}
\newabbreviation[category=symbol,symbol={$\mathring{A}$}]{a}{a}{lattice constant}
\begin{document}
First use \gls{mc}.
Next use \gls{mc}.
First use \gls{a}.
Next use \gls{a}.
Symbol \glssymbol{a}.
\glsresetall
First use plural \glspl{mc}.
Next use plural \glspl{mc}.
First use plural \glspl{a}.
Next use plural \glspl{a}.
\glsresetall
First use, first letter upper case \Gls{a}.
Next use, first letter upper case \Gls{a}.
\glsresetall
First use, all upper case \GLS{a}.
Next use, all upper case \GLS{a}.
\printglossary[style=index]
\end{document}
得出的结果为: