%%
%% This is file `intex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% intex.dtx  (with options: `intex')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2005--2008 by Martin Thorsen Ranang <mtr@ranang.org>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\def\filename{intex}%
\ProvidesPackage{intex}[2008/10/13 v1.1
Support for concept, acronym, and proper-name typesetting and indexing]%
\newif\if@itx@index%
\@itx@indextrue%
\DeclareOption{noindex}{\@itx@indexfalse}%
\newif\if@itx@warn@undef%
\@itx@warn@undeftrue%
\DeclareOption{nowarnundef}{\@itx@warn@undeffalse}%
\newif\if@itx@margin@plain%
\newif\if@itx@margin@acronym%
\newif\if@itx@margin@person%
\@itx@margin@plaintrue%
\@itx@margin@acronymtrue%
\@itx@margin@persontrue%
\DeclareOption{nomarginplain}{\@itx@margin@plainfalse}%
\DeclareOption{nomarginacronym}{\@itx@margin@acronymfalse}%
\DeclareOption{nomarginperson}{\@itx@margin@personfalse}%
\ProcessOptions%
\if@itx@index%
  \RequirePackage{index}%
  \makeindex%
  \newindex{raw}{rix}{rid}{Index}%
\else%
  \def\@nearverbatim{\expandafter\strip@prefix\meaning}%
\fi%
\if@itx@margin@plain%
  \RequirePackage{marginnote}[2006/10/26]%
\fi%
\if@itx@margin@acronym%
  \RequirePackage{marginnote}[2006/10/26]%
\fi%
\if@itx@margin@person%
  \RequirePackage{marginnote}[2006/10/26]%
\fi%
\RequirePackage{acronym}[2008/05/28]%
\RequirePackage{ifthen}%
\newcommand*{\InTeX}{\textsl{In}\kern-.07em\TeX}%
\newcommand\itxplaindeffont[1]{\emph{#1}}%
\newcommand\itxplainfollowfont[1]{#1}%
\newcounter{itxpl}%
\newcommand\@itxbasemarginfont[1]{%
  \stepcounter{itxpl}%
  \ifthenelse{\isodd{\pageref{itxpl-\theitxpl}}}{%
    \raggedright\hspace{0pt}\footnotesize\textsf{#1}% odd
  }{%
    \raggedleft\hspace{0pt}\footnotesize\textsf{#1}% even
  }%
  \label{itxpl-\theitxpl}%
}%
\newcommand\itxplainmarginfont[1]{%
  \@itxbasemarginfont{#1}%
}%
\newcommand{\itxacronymdeffont}[1]{#1}%
\newcommand{\itxacronymdefshortfont}[1]{\emph{#1}}%
\newcommand{\itxacronymshortfont}[1]{#1}%
\newcommand{\itxacronymmarginfont}[1]{%
  \@itxbasemarginfont{#1}%
  %\raggedleft\hspace{0pt}\footnotesize\textsf{#1}%
}%
\newcommand{\itxpersondeffont}[1]{\emph{#1}}%
\newcommand{\itxpersonfirstfont}[1]{#1}%
\newcommand{\itxpersonlastfont}[1]{#1}%
\newcommand{\itxpersonmarginfont}[1]{%
  \@itxbasemarginfont{#1}%
  %\raggedleft\hspace{0pt}\footnotesize\textsf{#1}%
}%
\newcounter{co@serial}%
\newcounter{co@type}%
\newcommand*\itxundefcomment[1]{\emph{(undefined concept ``#1'')}}%
\long\def\@firstofthree#1#2#3{#1}%
\long\def\@secondofthree#1#2#3{#2}%
\def\ITX@reset#1{%
  \global\expandafter\let\csname itx@#1\endcsname\relax}%
\newcommand*\@itxmarginlabel[2]{%
  \hspace{0pt}%
  \ifcase#1%
  % \ldots plain concept, \ldots
    \if@itx@margin@plain%
      \marginpar{\itxplainmarginfont{\ITX@itxs{#1}{#2}}}%
      %\marginnote{\itxplainmarginfont{\ITX@itxs{#1}{#2}}}%
    \fi%
  \or%
  % \ldots an acronym, \ldots
    \if@itx@margin@acronym%
      \marginpar{\itxacronymmarginfont{\ITX@itxs{#1}{#2}}}%
    \fi%
  \or%
  % \ldots or a person's name.
    \if@itx@margin@person%
      \marginpar{\itxpersonmarginfont{\ITX@itxl{#1}{#2}}}%
    \fi%
  \fi%
}%
\newcommand*\ITX@used{@<>@<>@}%
\newcommand*\ITX@get[2]{%
  \ifx#1\relax%
  \else%
    \expandafter#2#1%
  \fi%
}%
\newcommand*\itxplainarea{\thesubparagraph:\thepage}%
\newcommand*\itxacronymarea{\thechapter}%
\newcommand*\itxpersonarea{\thesubsubsection}%
\newcommand*\@itxarea[1]{%
  \ifcase#1%
    {\itxplainarea}%
  \or%
    {\itxacronymarea}%
  \or%
    {\itxpersonarea}%
  \fi%
}%
\def\itx@last@pos0{}%
\def\itx@last@pos1{}%
\def\itx@last@pos2{}%
\newcommand*\ITX@itxs[2]{%
  \csname fnss@\number#2\endcsname%
}%
\newcommand*\ITX@itxl[2]{%
  \csname fnsl@\number#2\endcsname%
}%
\newcommand*{\itxs}[2]{%
  \texorpdfstring{\protect\@itxs{#1}{#2}}{#1}}%
\newcommand*{\@itxs}[2]{%
  \ifcase\number#1%
    \itxplainfollowfont{\ITX@itxs{#1}{#2}}%
  \or%
    \itxacronymshortfont{\ITX@itxs{#1}{#2}}%
  \or%
    \itxpersonlastfont{\ITX@itxl{#1}{#2}}%
  \fi%
}%
\newcommand*{\itxl}{\protect\@itxl}%
\newcommand*{\@itxl}[2]{%
  %\ITX@itxl{#1}{#2}%
  \ifcase\number#1%
    \itxplainfollowfont{\ITX@itxs{#1}{#2}}\nolinebreak %
  \or%
    \itxacronymdeffont{\ITX@itxl{#1}{#2}}%
  \or%
    \itxpersondeffont{%
      \itxpersonfirstfont{\ITX@itxs{#1}{#2}} %
      %\nolinebreak[3] %
      \itxpersonlastfont{\ITX@itxl{#1}{#2}}%
    }%
  \fi%
}%
\newcommand*{\itxf}[2]{%
  \texorpdfstring{\protect\@itxf{#1}{#2}}{\ITX@itxl{#1}{#2} (#1)}%
}%
\newcommand*{\@itxf}[2]{%
  \ifcase\number#1%
    \@itxmarginlabel{#1}{#2}%
    \itxplaindeffont{\ITX@itxs{#1}{#2}}\nolinebreak %
  \or%
    \itxacronymdeffont{%
      \ITX@itxl{#1}{#2} %
      %\nolinebreak[3] %
      \@itxmarginlabel{#1}{#2}%
      \itxacronymdefshortfont{%
        \itxacronymshortfont{(\ITX@itxs{#1}{#2})}}%
    }%
  \or%
    \itxpersondeffont{%
      \itxpersonfirstfont{%
        \ITX@itxs{#1}{#2}} %
      %\nolinebreak[3] %
      \@itxmarginlabel{#1}{#2}%
      \itxpersonlastfont{%
        \ITX@itxl{#1}{#2}%
      }%
    }%
  \fi%
  \expandafter\ifx\csname itx@#2\endcsname\ITX@used%
    %\relax%
  \else%
    \global\expandafter\let\csname itx@#2\endcsname\ITX@used%
    %\ITX@addtoclearlist{#2}% MTR
  \fi%
  %\ITX@logged{#2} MTR
}%
\newcommand*{\@itxrecordarea}[2]{%
  % Record this area:
  \edef\curr@pos{\@itxarea{#1}}%
  %\PackageWarning{InTeX}{Current position for type "#1" is "\curr@pos"}%
  % Remember the last area where this concept (second argument) was used.
  \edef\last@pos{\csname itx@last@pos#1@#2\endcsname}%
  \ifx\curr@pos\last@pos%
    % We're still in the same area.  Hence, we do nothing.
  \else%
    % The area has changed.
    \ITX@reset{#2}%
  \fi%
  \expandafter\xdef\csname itx@last@pos#1@#2\endcsname{\curr@pos}%
}%
\newcommand\@itx@init@nonbookmode{%
  \newcommand*{\@itxtypeset}[3]{% Article-mode.
    \ifx##3A%
      %\PackageWarning{InTeX}{Typesetting format is automatic}%
      \expandafter\ifx\csname itx@##2\endcsname\ITX@used%
        \itxs{##1}{##2}%
      \else%
        \itxf{##1}{##2}%
      \fi%
    \else%
      %\PackageWarning{InTeX}{Typesetting format = "##3"}%
      \ifx##3S\itxs{##1}{##2}\fi%
      \ifx##3L\itxl{##1}{##2}\fi%
      \ifx##3F\itxf{##1}{##2}\fi%
    \fi%
  }%
}%
\newcommand\@itx@init@bookmode{%
  \PackageInfo{InTeX}{Adjusting behavior to suite book/report document
    classes\@gobble}%
  \newcommand*{\@itxtypeset}[3]{% Book/report-mode.
    \ifx##3A%
      %\PackageWarning{InTeX}{Typesetting format is automatic}%
      \if@mainmatter%
        \expandafter\ifx\csname itx@##2\endcsname\ITX@used%
          \itxs{##1}{##2}%
        \else%
          \itxf{##1}{##2}%
        \fi%
      \else%
        \itxl{##1}{##2}%
      \fi%
    \else%
      %\PackageWarning{InTeX}{Typesetting format = "##3"}%
      \ifx##3S\itxs{##1}{##2}\fi%
      \ifx##3L\itxl{##1}{##2}\fi%
      \ifx##3F\itxf{##1}{##2}\fi%
    \fi%
  }%
}
\newif\if@itx@bookmode%
\@itx@bookmodetrue%
\@ifclassloaded{article}{%
  \PackageInfo{InTeX}{Adjusting behavior to suite the article document
    class\@gobble}%
  \@itx@init@nonbookmode%
  \@itx@bookmodefalse%
}{}%
\@ifclassloaded{beamer}{%
  \PackageInfo{InTeX}{Adjusting behavior to suite the beamer document
    class\@gobble}%
  \@itx@init@nonbookmode%
  \@itx@bookmodefalse%
  \renewcommand*\itxacronymarea{0}%
  \@itx@margin@plainfalse%
  \@itx@margin@acronymfalse%
  \@itx@margin@personfalse%
}{}%
\if@itx@bookmode%
  \@itx@init@bookmode%
\fi%
\newcommand*{\@itxplain}[3]{%
  \@itxrecordarea{#1}{#2}%
  \@itxtypeset{#1}{#2}{#3}%
}%
\newcommand*{\@itxalias}[2]{%
  \edef\@mainserial{\expandafter\@firstoftwo#2}%
  \edef\@equivserial{\expandafter\@secondoftwo#2}%
  %\@itxrecordarea{#1}{\@mainserial}%
  \@itxplain{#1}{\@equivserial}%
}%
\newcommand{\@itx@fakeindex}[1]{%
  \begingroup%
    \edef\@tempa{%
      \write\@auxout{%
        \string\@writefile{raw}{%
          \string\indexentry{#1}{\thepage}%
        }%
      }%
    }%
  \expandafter\endgroup\@tempa%
}%
\newcommand{\co}{\@itx}%
\newcommand{\coS}[1]{\@itx[S]{#1}}%
\newcommand{\coL}[1]{\@itx[L]{#1}}%
\newcommand{\coF}[1]{\@itx[F]{#1}}%
\DeclareRobustCommand*{\@itx}[2][A]{%
  \def\@tempa{#2}%
  \edef\@tempb{\@nearverbatim\@tempa}%
  \if@itx@index%
    \index[raw]{#2}%
  \else%
    \@itx@fakeindex{\@tempb}%
  \fi%
  \newif\iffound%
  \setcounter{co@type}{0}%
  \loop\ifnum\theco@type<3%
    \expandafter\ifx\csname fn\number\theco@type e@\@tempb\endcsname\relax%
      \expandafter\ifx\csname fn\number\theco@type @\@tempb\endcsname\relax%
        % \PackageWarning{InTeX}{Main AND alias reference `#2' occurred}%
        % The reference refers to both main _and_ alias entries.  Do
        % nothing, this will be resolved through the |else|-cases
        % immediately below.
      \else%
        %\PackageInfo{InTeX}{Main reference `#2' occurred}%
        \edef\co@id{\csname fn\number\theco@type @\@tempb\endcsname}%
        \@itxplain{\number\theco@type}{\co@id}{#1}%
        \foundtrue%
      \fi%
    \fi%
    \stepcounter{co@type}%
  \repeat%
  \iffound%
  \else%
    \PackageWarning{InTeX}{Reference `#2' to undefined concept}%
    \if@itx@warn@undef%
      \textbf{\itxundefcomment{#2}}%
    \else%
      #2%
    \fi%
  \fi%
}%
\newcommand*{\personused}[1]{%
  \expandafter\ifx\csname pnused@#1\endcsname\PN@used%
    \relax%
  \else%
    \global\expandafter\let\csname pnused@#1\endcsname\PN@used%
    \global\let\PN@populated\PN@used%
  \fi%
}%
\newcommand\@itxdefineforms[3]{%
  \expandafter\gdef\csname fnss@\number#1\endcsname{#2}%
  \expandafter\gdef\csname fnsl@\number#1\endcsname{#3}%
}%
\newcommand\@newentry[4]{%
  \def\@tempa{#2}%
  \edef\@tempb{\@nearverbatim\@tempa}%
  %
  \stepcounter{co@serial}%
  %\PackageWarning{init}{serial counter = \expandafter\theco@serial}%
  \expandafter\xdef\csname fn\number#1@\@tempb\endcsname{%
    \number\theco@serial}%
  %\PackageWarning{init}{Def: \meaning\csname fn\number#1@\@tempb\endcsname}%
  \@itxdefineforms{\theco@serial}{#3}{#4}%
}%
\newcommand*\newconcept[3]{%
  \@newentry{0}{#1}{#2}{#3}%
}%
\newcommand*\newacronym[3]{%
  \@newentry{1}{#1}{#2}{#3}%
}%
\newcommand*\newperson[3]{%
  \@newentry{2}{#1}{#2}{#3}%
}%
\newcommand*\@newentryequiv[5]{%
  \newif\iffound%
  \def\@tempa{#2}%
  \edef\@tempb{\@nearverbatim\@tempa}%
  \expandafter\ifx\csname fn\number#1 @\@tempb\endcsname\relax%
  \else%
    \foundtrue%
    \edef\co@id{\csname fn\number#1@\@tempb\endcsname}%
    %\PackageWarning{init}{Found `\@tempb' (type=\number#1, serial=\co@id)}%
    \stepcounter{co@serial}%
    \@itxdefineforms{\theco@serial}{#3}{#5}%
    \def\@tempa{#4}%
    \edef\@tempb{\@nearverbatim\@tempa}%
    \expandafter\xdef\csname fn\number#1 e@\@tempb\endcsname{%
      {\co@id}{\theco@serial}}%
  \fi%
  \iffound%
  \else%
    %\PackageWarning{InTeX}{Can't find `#2' for sub-concept `#3'}%
  \fi%
}%
\newcommand*\newconceptequiv[4]{%
  \@newentryequiv{0}{#1}{#2}{#3}{#4}%
}%
\newcommand*\newacronymequiv[4]{%
  \@newentryequiv{1}{#1}{#2}{#3}{#4}%
}%
\newcommand*\newpersonequiv[4]{%
  \@newentryequiv{2}{#1}{#2}{#3}{#4}%
}%
\AtBeginDocument{\@input{\jobname.ito}}%
\endinput%
\endinput
%%
%% End of file `intex.sty'.
