5

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) . enter image description here

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}.
  • If you don't want to use the (a) afterwards, why do you introduce it at all? – Ulrike Fischer Sep 13 '13 at 13:19
  • 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. – cosmicraga Sep 13 '13 at 13:22
8

You can redefine the \gls command in this way

\let\oldgls\gls
\renewcommand{\gls}[1]{%
  \ifglsused{#1}%
    {\glsentrylong{#1}}%
    {\oldgls{#1}}%
}

Thus, the following 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} 

gives

enter image description here


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 loading glossaries, that is

\usepackage[shortcuts,acronym,xindy,sort=def,toc,numberline,indexonlyfirst,nomain]{glossaries}

Then substitute the code in the first part of the answer with

\let\oldac\ac
\renewcommand{\ac}[1]{%
  \ifglsused{#1}%
    {\glsdesc{#1}}%
    {\oldac{#1}}%
}

At this point replace \gls{a} with \ac{a}.

The result is:

enter image description here


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

\def\myacro{nomenc}

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

\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

Final MWE (I've also added sanitize=none option to allow TeX commands inside fiels)

\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} 

Result:

enter image description here

|improve this answer|||||
  • Done :) :). I would like to acknowledge your name in my thesis. Please give me your name and relevant details if you have no problem with it :) – cosmicraga Sep 14 '13 at 6:22
  • 4
    @cosmicraga thanks for your kindness, but I don't think it is necessary. At most, you can acknowledge "people at TeX.SX". – karlkoeller Sep 14 '13 at 6:48
  • If the plural form acronym is used first then it is printing one s after the symbol in parenthesis and this is not desired. Would you mind have a look please ? For example, if glspl{a} occurs first before any use of \gls{a} then it is printing lattice constants (as) instead of lattice constants (a). – cosmicraga Sep 15 '13 at 13:46
  • @cosmicraga I have the solution but I can not add it in the answer. In fact, the system doesn't permit answers that go over 30,000 characters... Do you want to ask a new question for that? – karlkoeller Sep 15 '13 at 15:49
  • Sure. I will ask it as new question. Thanks. – cosmicraga Sep 15 '13 at 17:32
1

Here's an alternative solution that uses glossaries-extra, which extends the glossaries package. It has the advantage that it can provide multiple abbreviation styles within the same document by assigning a different category for each abbreviation type.

Example:

\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}

This produces:

image of document

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.