-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeglo.sty
102 lines (93 loc) · 3.23 KB
/
makeglo.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
%%% makeglo.sty -- A simple package for glossary generation.
%%% $Id: makeglo.sty,v 1.5 2000/05/07 23:09:37 jessen Exp $
%%%
%%% This package defines the commands \Glossary, \printglossary and
%%% the environments theglossary and glossdescription. Must be used
%%% with the makeindex style file `makeglo.ist'.
%%%
%%% Written by Klaus Steding-Jessen <jessen@acm.org>
%%% This package is based on the nomencl package by Boris Veytsman
%%% <boris@plmsc.psu.edu>
%%%
%%% Usage:
%%%
%%% In the preable:
%%% \usepackage{makeglo}
%%% \renewcommand{\glossaryname}{Name of the Glossary}
%%% \renewcommand{\glossmaxlabelwidth}{width} % optional
%%% \makeglossary
%%%
%%% Example:
%%% \renewcommand{\glossaryname}{Glossary}
%%% \renewcommand{\glossmaxlabelwidth}{\hspace{2cm}} or
%%% \renewcommand{\glossmaxlabelwidth}{My longest entry}
%%% \makeglossary
%%%
%%% In the document:
%%% \Glossary[how_to_display_entry]{entry}{explanation}
%%%
%%% Examples:
%%% \Glossary{foo}{foo explanation}
%%% \Glossary[$\alpha$]{alpha}{alpha explanation}
%%%
%%% In the document, where the glossary must be printed:
%%% \clearpage
%%% \printglossary
%%%
%%% Processing the document with latex and makeindex:
%%% latex document
%%% makeindex -s makeglo.ist -o document.gls document.glo
%%% latex document
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{makeglo}
\RequirePackage{ifthen}
%%% Name of the Glossary. You may change this in your document
%%% using, for example: \renewcommand{\glossaryname}{Definitions}
%\newcommand{\glossaryname}{Glossary} % by ffs
%%% Width of the entry column. You may change this in your document
%%% using, for example:
%%% \renewcommand{\glossmaxlabelwidth}{\hspace{2cm}} or
%%% \renewcommand{\glossmaxlabelwidth}{My longest entry}
\newcommand{\glossmaxlabelwidth}{\hspace{1in}}
\newcommand{\glosspage}[1]{\relax}
\newcommand{\glossgroup}[1]{}
\newcommand{\glossprefix}{a}
\newcommand{\glossoutput}{}
\newlength{\glossentrylen}
\newenvironment{glossdescription}[1]%
{\list{}
{\settowidth{\labelwidth}{\textbf{#1}}%
\leftmargin\labelwidth\advance\leftmargin\labelsep%
\renewcommand{\makelabel}[1]{%
\settowidth{\glossentrylen}{\textbf{##1}}%
\ifthenelse{\lengthtest{\glossentrylen > \labelwidth}}%
{\parbox[b]{\labelwidth}%
{\makebox[0pt][l]{\textbf{##1}}\\\mbox{}}}
{\textbf{##1}}%
\hfill\relax%
}
}}
{\endlist}
\ifx\@undefined\chapter
\newenvironment{theglossary}{% article-like documents
\section*{\glossaryname}\begin{glossdescription}{\glossmaxlabelwidth}}{%
\end{glossdescription}}
\else
\newenvironment{theglossary}{% report/book-like documents
\chapter*{\glossaryname}
\begin{glossdescription}{\glossmaxlabelwidth}}{%
\end{glossdescription}}
\fi
\newcommand{\Glossary}[3][]{%
\ifthenelse{\equal{#1}{}}%
{\renewcommand{\glossoutput}{#2}}%
{\renewcommand{\glossoutput}{#1}}%
\ignorespaces%
\protected@write\@glossaryfile{}%
{\string\glossaryentry{\glossprefix#2@[\glossoutput]#3%
\protect|glosspage}{\thepage}}}
\newcommand{\printglossary}{%
\clearpage % by ffs
\addcontentsline{toc}{chapter}{\glossaryname} % by ffs
\InputIfFileExists{\jobname.gls}{}{\typeout{No file \jobname.gls}}}
%%% makeglo.sty ends here.