Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using 'glossaries' to make index after my book, I set the numberlist to section, so the number of the section will in the numberlabel. eg:

                               INDEX
Unix, a multitasking, multi-user computer operating system  1
Unix-like, operating system is one that behaves in a manner similar to a Unix system 2  

It means that the word Unix is in the section 1, the word Unix-like is in section 2.

But right now I have some sections whose names are not genarated by default, they are defined manually by the commands as follows:

\section*{2a Linux}

The meanest code is as follows:

\documentclass{book}
\renewcommand\thesection{\arabic{section}}
\usepackage[counter=section]{glossaries}
\makeglossaries


\newglossaryentry{Unix}{
name={Unix},
description={a multitasking, multi-user computer operating system}
}
\newglossaryentry{Unix-like}{
name={Unix-like},
description={operating system is one that behaves in a manner similar to a Unix system}
}
\newglossaryentry{Linux}{
name={Linux},
description={Linux was originally developed as a free operating system}
}
\newglossaryentry{FreeBSD}{
name={FreeBSD},
description={a free Unix-like operating system, an operating system}
}
\newglossaryentry{Windows}{
name={Windows},
description={a series of graphical interface operating systems}
}
\newglossaryentry{Mobile Operating System}{
name={Mobile Operating System},
description={the operating system that operates a smartphone...}
}


\begin{document}
\section{Unix}
Unix \glsadd{Unix} (officially trademarked as UNIX, sometimes also written as Unix) is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT\&T employees at Bell Labs.

\section{Unix-like}
A Unix-like \glsadd{Unix-like}(sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification.

\section*{2a \quad Linux}
Linux \glsadd{Linux}was originally developed as a free operating system for Intel x86-based personal computers. It has since been ported to more computer hardware platforms than any other operating system.

\section*{2alpha \quad FreeBSD}
FreeBSD \glsadd{FreeBSD} is a free Unix-like operating system descended from AT\&T UNIX via BSD UNIX.  Although for legal reasons FreeBSD cannot be called "UNIX".

\section{Windows}
Microsoft Windows \glsadd{Windows}is a series of graphical interface operating systems developed, marketed, and sold by Microsoft.

\section*{3delta \quad Mobile Operating System}
A mobile operating system \glsadd{Mobile Operating System}, also referred to as mobile OS, is the operating system that operates a smartphone, tablet, PDA, or other digital mobile devices.

\printglossary
\end{document}

So, if some entries are in these manually defined sections, the 'glossaries' can not read the number of setions then the numberlists of these entries don't work. Right now it looks like:

                            INDEX
Unix, a multitasking, multi-user computer operating system  1
Unix-like, operating system is one that behaves in a manner similar to a Unix system 2
Linux,Linux was originally developed as a free operating system 2
FreeBSD, a free Unix-like operating system, an operating system  2
Windows, a series of graphical interface operating systems 3
Mobile Operating System, the operating system that operates a smartphone... 3

Actually, It should like this:

                            INDEX
Unix, a multitasking, multi-user computer operating system  1
Unix-like, operating system is one that behaves in a manner similar to a Unix system 2
Linux,Linux was originally developed as a free operating system 2a
FreeBSD, a free Unix-like operating system, an operating system  2alpha
Windows, a series of graphical interface operating systems 3
Mobile Operating System, the operating system that operates a smartphone... 3delta

How to resolve these problems? How to make 'glossaries' can read the number of sections which were defined manually correctly?

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

The glossaries package writes the location as the value of the counter assigned to the particular entry, so you can't just specify a particular location as a string. In addition, makeindex only understands a limited number of location styles (arabic, roman and alph), so if you have any location that doesn't fit that style you will have to use xindy. Here's a possible solution:

\documentclass{book}
\renewcommand\thesection{\arabic{section}}
\usepackage[counter=section,xindy]{glossaries}

\newcounter{sectionalph}
\newcounter{sectiongreek}

\renewcommand{\thesectionalph}{\thesection\alph{sectionalph}}
\renewcommand{\thesectiongreek}{\thesection\greekstring{sectiongreek}}

\newcommand{\greekstring}[1]{%
  \ifcase\value{#1}\relax
  \or
   alpha%
  \or
   beta%
  \or
   gamma%
  \or
   delta%
  \or
   epsilon%
  \or
   zeta%
  \or
   eta%
  \or
   theta%
  \or
   iota%
  \or
   kappa%
  \or
   lambda%
  \or
   mu%
  \or
   nu%
  \or
   omicron%
  \or
   pi%
  \or
   rho%
  \or
   sigma%
  \or
   tau%
  \or
   upsilon%
  \or
   phi%
  \or
   chi%
  \or
   xi%
  \or
   psi%
  \or
   omega%
  \fi
}

\GlsAddXdyCounters{sectionalph}
\GlsAddXdyCounters{sectiongreek}

\GlsAddXdyAlphabet{greek}{"alpha" "beta" "gamma" "delta"
"epsilon" "zeta" "eta" "theta" "iota" "kappa" "lambda" "mu"
"nu" "omicron" "pi" "rho" "sigma" "tau" "upsilon" "phi"
"chi" "xi" "psi" "omega"}

\GlsAddXdyLocation{sectiongreek}{
  "arabic-numbers" "greek"}

\makeglossaries

\newcommand{\sectionalph}[1]{%
  \refstepcounter{sectionalph}%
  \section*{\thesectionalph\quad #1}%
}

\newcommand{\sectiongreek}[1]{%
  \refstepcounter{sectiongreek}%
  \section*{\thesectiongreek\quad #1}%
}

\newglossaryentry{Unix}{
name={Unix},
description={a multitasking, multi-user computer operating system}
}
\newglossaryentry{Unix-like}{
name={Unix-like},
description={operating system is one that behaves in a manner
similar to a Unix system}
}
\newglossaryentry{Linux}{
name={Linux},
description={Linux was originally developed as a free operating
system}
}
\newglossaryentry{FreeBSD}{
name={FreeBSD},
description={a free Unix-like operating system, an operating system}
}
\newglossaryentry{Windows}{
name={Windows},
description={a series of graphical interface operating systems}
}
\newglossaryentry{Mobile Operating System}{
name={Mobile Operating System},
description={the operating system that operates a smartphone...}
}


\begin{document}
\section{Unix}
Unix \glsadd{Unix} (officially trademarked as UNIX, sometimes also
written as Unix) is a multitasking, multi-user computer operating
system originally developed in 1969 by a group of AT\&T employees at
Bell Labs.

\section{Unix-like}
A Unix-like \glsadd{Unix-like}(sometimes referred to as UN*X or
*nix) operating system is one that behaves in a manner similar to a
Unix system, while not necessarily conforming to or being certified
to any version of the Single UNIX Specification.

\sectionalph{Linux}
Linux \glsadd[counter=sectionalph]{Linux}was originally developed as a free operating
system for Intel x86-based personal computers. It has since been
ported to more computer hardware platforms than any other operating
system.

\sectiongreek{FreeBSD}
FreeBSD \glsadd[counter=sectiongreek]{FreeBSD} is a free Unix-like operating system
descended from AT\&T UNIX via BSD UNIX.  Although for legal reasons
FreeBSD cannot be called "UNIX".

\section{Windows}
Microsoft Windows \glsadd{Windows}is a series of graphical interface
operating systems developed, marketed, and sold by Microsoft.

\sectiongreek{Mobile Operating System}
A mobile operating system \glsadd[counter=sectiongreek]{Mobile Operating System}, also
referred to as mobile OS, is the operating system that operates a
smartphone, tablet, PDA, or other digital mobile devices.

\printglossary
\end{document}
share|improve this answer
5  
Welcome to TeX.SX! If you register you can better enjoy the site and we can more easily benefit from your expertise! –  egreg Oct 13 '12 at 11:10
4  
Hi Nicola, welcome to our community! It's an honour to have you here with us! :) –  Paulo Cereda Oct 13 '12 at 11:22
2  
A pleasure having you here! –  Gonzalo Medina Oct 14 '12 at 0:57
    
There are still two issues: 1.a suspect BUG. The parameter \alph doesn't work fine in my MAC OSX, when the counter is bigger than 6, in the section it is 2f, 2g, 2h, there will be something wrong. So I have to use \newcommand{\alphstring} and define \GlsAddXdyAlphabet{alph} from a to z manually same as greekstring and greek. –  WonderTree Oct 14 '12 at 3:37
1  
@WonderTree \newcounter has an optional argument (which comes after the mandatory argument) where you can specify the parent counter. More detail at (dickimaw-books.com/latex/novices/html/counters.html) and (tex.ac.uk/cgi-bin/texfaq2html?label=addtoreset) –  Nicola Talbot Oct 15 '12 at 7:35
show 7 more comments

I think it need not concern Makeindex or Xindy. These entries are not in the Sectional Units which are unnumbered, they are in the Section Units which have been manually numbered, eg 2a, 2alpha, 3delta etc. They were actually defined by author with for example

\section*{2a  Linux}

So the solution is very simple, since they need be defined manually, then we can add one parameter to supply the number of these sectin for glossaries. If the number of this section is '2a', it could look like in the preamble:

\newcommand\mysection[2]{
    \section*{{#1}\quad{#2}}
    \addcontentsline{toc}{section}{{#1}\quad{#2}}
    \markright{{#1}\quad{#2}}
%----------------------
\addglodiynumberofsec{#1}

%----------------------
    }

There parameter #1 is the manully defined number of the section, #2 is its' name. We just need add a new function '\add-glo-diy-number-of-sec' in package 'glossaries' to make it true

that glossaries can read the #1, and in the tex we just need

\mysection{2a}{Linux}

then, the glossaries can use the location---- 2a

All in one, we just need add a new funcion

 \addglodiynumberofsec

or in some other names in glossaries. It's resolved.

But I'm not a programmer, I can't modify the code of glossaries, so here asking for help.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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