10

I need to print in the acronym list the page number of first occurrence of an acronym in the text, not the page numbers of the subsequent occurrences. How can I achieve that ?

I have defined my acronyms in a separate file. Though in the MWE, I have defined two acronyms in the main body itself.

In the MWE, the acronym MC appears in the 1st and 3rd page, for example. I want only page number 1 (the first occurence) to be there in the list of acronyms.

I also need to add units after the description in the acronym list. For example, in the second acronym, the unit angstrom beside "bond length", followed by page number of first occurrence of L.

For all the comumns, I need to add column names:

Symbol ....... Name and Units ....... First used on Page No.

The dots means white space.

The MWE

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

Following is the custom glossary style from manual

%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

How do I delete SYMBOLS and DIMENSION from the above style? How do I define the acronyms ?

  • Could you add a minimal working example (MWE), please? – clemens Aug 1 '13 at 8:37
  • You can use the user keys to specify the units and create your own glossary style (examples are in the user manual). I am not aware of any way to only link to the first use. – Alex Grede Aug 1 '13 at 15:43
  • 2
    indexonlyfirst as package option is the trick for only first use. I have put the new glossary style and its working, but I do not need all those fields and I am struggling in defining new acronym. I am editing with the new glossary style. Help appreciated – cosmicraga Aug 1 '13 at 19:49
4

I suspect the reason why this question has remained unanswered for two years is because it's actually more than one question which doesn't fit in with the way this site works, but it needs to be either answered or closed to get it off the unanswered list.

Your first question (and the question title) you have already answered in a comment. The package option indexonlyfirst will only add the first use to the location list.

MWE:

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

Your second question (which really ought to be a separate post) is a little confusing.

For all the comumns, I need to add column names:

Symbol ....... Name and Units ....... First used on Page No.

The dots means white space.

This suggests a 3-column tabular layout, but your example code has six columns. Assuming that you're storing the unit in the user1 field and by "Symbol" you mean the short form (such as L) and by "Name" you mean the long form (such as bond length) then the following will produce a three column style (I've just used \AA for the ångström sign for simplicity, but it would be better to use siunitx to deal with the units):

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

This produces:

image of glossary

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.