I have a probably strange requirement.
Normally in nomenclature
using glossaries
package, the symbol is the only thing printed after the first use onwards, but i need the opposite. After first use onwards, only the symbol definition should be printed, not the symbol.
Example:
I have defined the following nomenclature
\newacronym[user1={--}]{a}{\textit{a}}{lattice constant}
now when I use it like \gls{a}
, it expands like lattice constant (a)
in the first use and after the first use onwards, it only prints a
. I want opposite. I want lattice constant
to be printed after first use onwards and suppress a
.
Because these symbols are used in equations and in the text, I need to say what the symbol is (yes, I have a separate list of Nomenclatures, but I need to explain the symbol once in the text). Now, occasionally, I have to use same symbol for different variables, so to use the symbol in text like the usual nomenclature creates confusion, so I need to use the full form.
Is it possible?
MWE
\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}
Nomenclatures are defined in file INP-00-glossary
\newacronym[user1={$\AA$}]{a}{\textit{a}}{lattice constant}
Abbreviations are defined in file INP-01-glossary
\newglossaryentry{MC}
{
name={MC},
description={Monte Carlo},
first={\glsentrydesc{MC} (\glsentrytext{MC})}
}
Further Request:
The features like 3) to 7) would be great addition. The picture is used only to describe the new request. The further request is extension of previous feature (i.e., only print definition, not symbol, after second use onwards, only for Nomenclature, not for Glossary) .
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}.
Best Answer
You can redefine the
\gls
command in this wayThus, the following MWE
gives
Edit
Your request can be achieved, but since
\gls
can not distinguish whether the item comes from the Nomenclature or from the other one, you will have to use\ac
instead of\gls
for nomenclature items.First of all, you have to add the option
shortcuts
when loadingglossaries
, that isThen substitute the code in the first part of the answer with
At this point replace
\gls{a}
with\ac{a}
.The result is:
Final Edit
To achieve all your latest requests, we have to deeply hack
glossaries.sty
code...Forget all the things we've mentioned before.
First of all, we define a new command
If you change the name of the Nomenclature, you will have to change
nomenc
to the new name.Then add all the following code in the preamble
Final MWE (I've also added
sanitize=none
option to allow TeX commands inside fiels)Result: