summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gatech-thesis/gatech-thesis-losa.sty
blob: 7b6cc1626f0e1913d1b3ef6830af887453844eab (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%% gatech-thesis-losa.sty - support code for creating a 'List of 
%%   Symbols or Abbreviations"
%%
%%   depends on gloss.sty, so it is not included by default in the
%%   main gatech-thesis.cls (this cuts down on ``extra'' dependencies
%%
%% To use this package, all you need do is include
%%   \usepackage{gatech-thesis-losa}
%%   \losafiles{<database file, sans .bib suffix>}
%% in your preamble, and the LOSA will be automatically generated
%% and included in the frontmatter.  Of course, you need actual
%% *entries* in the glossary file -- which must end in .bib -- and you
%% need actual citations to those entries within your bodytext, like this:
%%   \losa{key}.
%% Note that \losa{<key>} typesets the <word> from the <key> entry of
%% the losafile within the text, so there''s no need to do this:
%%    (BAD) word\losa{key-for-word} 
%% Again, you should read the gloss.sty documentation for more info, but
%% basically gatech-thesis-losa.sty makes it simple:
%%     1. insert the two commands above into your preamble
%%     2. create a database with your glossary definitions
%%     3. sprinkle \losa{} citations in your text
%%     4. run ``bibtex'' on the <rootfile>.losa.aux file created
%%        after the first ``latex'' run.  (But don''t include the
%%        .aux extension.  So say ``bibtex <rootfile>.losa''  You
%%        can do this at the same time you run ``bibtex'' for your
%%        references. 
%%     5. run ``latex'' twice more
%%
\NeedsTeXFormat{LaTeX2e}[1995/06/01] 
\ProvidesPackage{gatech-thesis-losa}
          [2002/08/08  List of Symbols support for gatech-thesis.cls]
\@ifclassloaded{gatech-thesis}{}{
  PackageError{This style can only be used with the gatech-thesis class}
}
\RequirePackage[refpages]{gloss}

\newif\iflosapage
\losapagetrue % why use this package if you're not going to USE it?

\newcommand{\losafiles}[1]%
  {\ifx\empty#1\empty\else\gdef\@losafiles{#1}\fi}
\def\@losafiles{}

\newcommand{\losaname}{}
\newcommand{\gtlosaname}{}
\newcommand{\losacontentlinestring}{}
\newcommand{\losapdfbookmarkstring}{}

\newcommand{\setlosastring}[1]{%
  \renewcommand{\gtlosaname}{#1}
  \renewcommand{\losaname}{\Makeuppercase{#1}}
  \renewcommand{\losacontentlinestring}{%
    \texorpdfstring{\Makeuppercase{#1}}{#1}
  }
  \renewcommand{\losapdfbookmarkstring}{#1}
}
\setlosastring{List of Symbols or Abbreviations}

\makegloss
\newgloss{losa}{.losa}{\losaname}{gatech-thesis-losa}
\newlength{\losahang}
\setlength{\losahang}{2cm}

\newcommand\setlosagroup[1]{\@namedef{gls@group@#1}}
\newcommand{\losaheading}[1]{} % don't print subsection headings ("A", "B", ...)
\newcommand{\losagroup}[1]{%
  \expandafter\losaheading\csname gls@group@#1\endcsname}

% make the '\losa[otheroptions]{}' command a synonym for 
% '\gloss[losa,otheroptions]{}'
\newcommand\losa{\protect\losa@gloss@i}
\def\losa@gloss@i{%
  \@bsphack
  \begingroup
    \catcode`\ =9
    \@ifnextchar[{\losa@gloss@iia}{\losa@gloss@iib[]}}
\def\losa@gloss@iia[#1]{%
    \endgroup
  \gls@gloss@iii{losa,#1}}
\def\losa@gloss@iib[#1]{% #1 is empty
    \endgroup
  \gls@gloss@iii{losa}}

% and alternate forms
\newcommand\Losa[1]{\losa[Word]{#1}}
\newcommand\onlylosa[1]{\losa[nocite]{#1}}

\newenvironment{losalist}
  {\begin{singlespaced}\begin{list}{\relax}{%
        \def\makelabel##1{##1\hfil}%
        \setlength{\labelsep}{1em}%
        \setlength{\labelwidth}{\losahang}%
        \addtolength{\labelwidth}{-\labelsep}%
        \setlength{\itemindent}{0em}%
        \setlength{\leftmargin}{\losahang}}}
  {\end{list}\end{singlespaced}}

\newenvironment{losaitem}[4]%
  {\ifgls@list
     \expandafter\let\expandafter\gls@thispage  % relax if undefined
             \csname glsp@\gls@name::#1\endcsname
     \item[%
       \gls@raisedlink{\hyper@anchorstart{\gls@name::#1}\hyper@anchorend}%
       \gls@label{#2}{#3}{#4}]%
     \begingroup
       \let\protect\noexpand
       \immediate\write\@auxout{%
         \string\gls@cite{\gls@name::#1}{#2}{#3}{#4}}%
     \endgroup
   \else
     \xdef\gls@a{\noexpand\begin{\@currenvir}}%
     \endgroup
     \begin{losalist}%
     \gls@listtrue
     \def\stopglosslist{\end{losalist}}%
     \gls@a{#1}{#2}{#3}{#4}%
   \fi
   \ignorespaces}
  {.\@@par}

\expandafter\let\csname losaitem*\endcsname\losaitem
\expandafter\let\csname endlosaitem*\endcsname\@@par

\newcommand\losa@section{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \chapter*{\losaname}%
  \@mkboth{\scshape\MakeUppercase\losaname}%
          {\scshape\MakeUppercase\losaname}%
}
\newenvironment{thelosa}
  {\losa@section
   \def\+##1+{}%
   \@beginparpenalty\@M}%  
  {\if@restonecol\twocolumn\fi%
  \stopglosslist}
  
\renewcommand{\do@losapage}{%
  \iflosapage
    \if@openright\cleardoublepage\else\clearpage\fi 
    % must clear page here, so that phantomsection\addcontentsline is on the correct page
    \settoheight{\gt@tmpa}{A}
    \set@gttocskip{\gt@tmpa}
    {\newlinestretch{1}
     \addvspace{\gt@tocentryskip@value}
     \phantomsection%
     \addcontentsline{toc}{chapter}{\losacontentlinestring}
     \printgloss[losa]{\@losafiles}
    }%
    \newpage
  \fi
}