%%
%% This is file `acroterm.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% acroterm.dtx  (with options: `package')
%% 
%% The Acroterm package
%% 
%% Copyright (C) 2010 by Jakob Voss
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status)
%% by Jakob Voss.
%% 
%% This work consists of the file  acroterm.dtx
%%           and the derived files acroterm.sty,
%%                                 acroterm.ins, and
%%                                 acroterm.pdf.
%% 
\ProvidesPackage{acroterm}
  [2010/11/19 v0.1 Manage and index acronyms and terms]
\RequirePackage{splitidx}[2009/02/18 v1.1a]
\RequirePackage{xifthen}
\newcommand{\Acrostyle}[1]{#1}
\newcommand{\acrostyle}[1]{\textsc{\lowercase{#1}}}
\newcommand{\termstyle}[1]{#1}
\newcommand{\Termstyle}[1]{\textit{#1}}
\newcommand{\tacrostyle}[2]{\termstyle{#1} (\acrostyle{#2})}
\newcommand{\Tacrostyle}[2]{\Termstyle{#1} (\acrostyle{#2})}
\newcommand{\atermstyle}[2]{\acrostyle{#1} (\termstyle{#2})}
\newcommand{\Atermstyle}[2]{\acrostyle{#1} (\termstyle{#2})}
\newcommand{\acroindexstyle}[1]{#1\acroexpand[ --- ]{#1}}
\newcommand{\provideacronym}[2]{% TODO: detect redefinitions
  \expandafter\providecommand\expandafter{%
  \csname acronymlong#1\endcsname}{#2}%
}
\newcommand{\bfhref}[1]{\textbf{\hyperpage{#1}}}
\newcommand{\acro@define}[2]{% #1: long term, #2: acronym
  \sindex[idx]{#1|see{\acrostyle{#2}}}% TODO: acronyms in general index?
  \@ifundefined{acronymlong#2}{%
    \provideacronym{#2}{#1}}{}%
  \sindex[acronym]{#2@\acroindexstyle{#2}|bfhref}%
}

\newcommand{\acroexpand}[2][]{%
  \@ifundefined{acronymlong#2}{}{%
  #1\csname acronymlong#2\endcsname}%
}
\newcommand{\term}[2][]{%
  \ifthenelse{\isempty{#1}}%
  {\sindex[idx]{#2}}{\sindex[idx]{#1}}%
  \termstyle{#2}}
\newcommand\Term[2][]{%
  \ifthenelse{\isempty{#1}}%
  {\sindex[idx]{#2|bfhref}}%
  {\sindex[idx]{#1|bfhref}}%
  \Termstyle{#2}%
}
\newcommand{\acro}[1]{%
  \acrostyle{#1}%
  {\sindex[acronym]{#1@\acroindexstyle{#1}}}%
}
\newcommand{\Acro}[1]{%
  \Acrostyle{#1}%
  {\sindex[acronym]{#1@\acroindexstyle{#1}}}%
}
\newcommand{\tacro}[3][]{%
  \ifthenelse{\isempty{#1}}%
  {\acro@define{#2}{#3}}{\acro@define{#1}{#3}}% TODO: not define?
  \tacrostyle{#2}{#3}}
\newcommand{\Tacro}[3][]{%
  \ifthenelse{\isempty{#1}}%
  {\acro@define{#2}{#3}}{\acro@define{#1}{#3}}%
  \Tacrostyle{#2}{#3}}
\newcommand{\aterm}[2]{%
  \acro@define{#2}{#1}% TODO: not define but only use?
  \atermstyle{#1}{#2}}
\newcommand{\Aterm}[2]{%
  \acro@define{#2}{#1}%
  \Atermstyle{#1}{#2}}
\endinput
%%
%% End of file `acroterm.sty'.
