%%
%% This is file `spelatex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% spelatex.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2024 by Walter Daems <walter.daems@ieee.org>
%%                   and Paul Levrie
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3 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.3 or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{spelatex}
   [2024/06/21 v0.91 SpeLaTeX - Speech-enabled LaTeX (DMW and LVP)]
\def\fileversion{0.91}
\def\filedate{2024/06/21}


%%

\RequirePackage{expl3}
\RequirePackage{hyperref}
\RequirePackage{xcolor}
\RequirePackage{ifthen}
\RequirePackage{fancyvrb}
\RequirePackage{newfile}
\RequirePackage{rotating}
\RequirePackage{babel}
\hypersetup{backref=true,
            breaklinks=true,
            colorlinks=true,
            citecolor=black,
            filecolor=black,
            hyperindex=true,
            linkcolor=black,
            pageanchor=true,
            pagebackref=true,
            pagecolor=black,
            pdfpagemode=UseOutlines,
            bookmarksopen=true,
            urlcolor=black}
\RequirePackage{kvoptions}
\RequirePackage{xkeyval}
\RequirePackage{marginnote}
\SetupKeyvalOptions{
  family=spel,
  prefix=spel@
}
\DeclareStringOption[ogg]{format}
\DeclareBoolOption[false]{disabled}
\DeclareBoolOption[false]{extramath}
\DeclareBoolOption[false]{propermath}
\ProcessKeyvalOptions*
\DeclareRobustCommand{\spelatex}{S\kern-0.3ex\raisebox{-0.1ex}{\rotatebox{-15}{p}}\kern-0.25ex\raisebox{0.1ex}{\rotatebox{10}{e}}\kern-0.1ex\LaTeX}
\DeclareRobustCommand{\spelbox}{S\kern-0.3ex\raisebox{-0.1ex}{\rotatebox{-15}{p}}\kern-0.25ex\raisebox{0.1ex}{\rotatebox{10}{e}}\kern-0.1exLbo\raisebox{-0.2ex}{x}}
\DeclareRobustCommand{\spelpl}{\texttt{spel-wizard.pl}}
\newoutputstream{chunk}
\newoutputstream{spelidx}
\openoutputfile{\jobname.spelidx}{spelidx}
\AtEndDocument{
  \closeoutputstream{spelidx}%
}
\newcommand\audiodir{\jobname-spel}
\newcommand\chunkdir{\jobname-spel}
\addtostream{spelidx}{format|\spel@format}
\addtostream{spelidx}{audiodir|\audiodir}
\addtostream{spelidx}{chunkdir|\chunkdir}
\ifspel@disabled\newcommand{\spel@idxwrite}[2]{}\else
\newcommand{\spel@idxwrite}[2]{%
  \typeout{spel: Generating #1 - #2}%
  \addtostream{spelidx}{#1|#2}%
}
\fi
\ifspel@disabled\newcommand{\spel@chunkwrite}[2]{}\else
\newcommand{\spel@chunkwrite}[2]{%
  \openoutputfile{\audiodir/#1.tex}{chunk}%
  \addtostream{chunk}{#2}%
  \closeoutputstream{chunk}%
}
\fi
\newcounter{spel@spart}
\renewcommand\thespel@spart{\@arabic\c@spel@spart}
\setcounter{spel@spart}{0}
\ifx\c@chapter\@undefined
\else
\ifx\c@part\@undefined
\newcounter{spel@schapter}
\else
\newcounter{spel@schapter}[part]
\fi
\renewcommand\thespel@schapter{\@arabic\c@spel@schapter}
\setcounter{spel@schapter}{0}
\fi
\ifx\c@chapter\@undefined
\newcounter{spel@ssect}
\else
\newcounter{spel@ssect}[chapter]
\fi
\renewcommand\thespel@ssect{\@arabic\c@spel@ssect}
\setcounter{spel@ssect}{0}
\newcounter{spel@footnote}
\renewcommand\thespel@footnote{\@arabic\c@spel@footnote}
\setcounter{spel@footnote}{0}
\newcounter{spel@chunk}[subparagraph]
\renewcommand\thespel@chunk{\@arabic\c@spel@chunk}
\setcounter{spel@chunk}{0}
\AddBabelHook{informspel}{write}{\spel@idxwrite{language}{\languagename}}
\EnableBabelHook{informspel}
\ifspel@disabled\newcommand{\spel@registerelement}[1]{}\else
\newcommand{\spel@registerelement}[1]{%
  \expandafter\let\csname spel@@#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\gdef\csname #1\endcsname##1{%
    \spel@chunkwrite{#1}{##1}
    \csname spel@@#1\endcsname{\href{run:\audiodir/#1.\spel@format}{##1}}
  }
  \expandafter\AtBeginDocument{
    \spel@idxwrite{#1}{#1}
  }
}
\fi
\spel@registerelement{title}
\spel@registerelement{date}
\spel@registerelement{author}
\ifspel@disabled\else
\let\spel@@addcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
  \let\spel@@href\href%
  \renewcommand\href[2]{#2}%
  \spel@@addcontentsline{#1}{#2}{#3}%
  \let\href\spel@@href%
}
\providecommand{\tableofcontents}{}
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \@ifclassloaded{article}{\section*{\contentsname}}{\chapter*{\contentsname}}
        \@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }
\fi
\ifspel@disabled\else
\let\spel@@part\@part
\def\@part[#1]#2{%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@part[#1]{\href{run:\audiodir/\spel@@optpart.\spel@format}{#2}}%
  \spel@idxwrite{part \thepart}{\spel@@optpart}%
  \spel@chunkwrite{\spel@@optpart}{#2}%
}
\fi
\ifspel@disabled\else
\let\spel@@spart\@spart
\def\@spart#1{%
  \stepcounter{spel@spart}%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@spart{%
    \href{run:\audiodir/\spel@@optpart star-\thespel@spart.\spel@format}{#1}}%
  \spel@idxwrite{part}{\spel@@optpart star-\thespel@spart}%
  \spel@chunkwrite{\spel@@optpart star-\thespel@spart}{#1}%
}
\fi
\ifspel@disabled\else
\ifx\chapter\@undefined\else
\let\spel@@chapter\@chapter
\def\@chapter[#1]#2{%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@chapter[#1]{%
    \href{run:\audiodir/\spel@@optpart\thechapter.\spel@format}{#2}}%
  \spel@idxwrite{chapter \thechapter}{\spel@@optpart\thechapter}%
  \spel@chunkwrite{\spel@@optpart\thechapter}{#2}%
}
\fi
\fi
\ifspel@disabled\else
\ifx\schapter\@undefined\else
\let\spel@@schapter\@schapter
\def\@schapter#1{%
  \stepcounter{spel@schapter}%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@schapter{%
    \href{run:\audiodir/\spel@@optpart star-\thespel@schapter.\spel@format}{#1}}%
  \spel@idxwrite{chapter}{\spel@@optpart star-\thespel@schapter}%
  \spel@chunkwrite{\spel@@optpart star-\thespel@schapter}{#1}%
}
\fi
\fi
\ifspel@disabled\else
\let\spel@@sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
  % correct default tex behavior
  \ifnum #2>\c@secnumdepth%
  \stepcounter{#1}%
  \fi%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{%
    \href{run:\audiodir/\spel@@optpart\thesubparagraph.\spel@format}{#8}\hfill%
    \href{run:\audiodir/\spel@@optpart\thesubparagraph.m3u}{\textcolor{black!25}{$\triangleright$}}}%
  \def\spel@@label{\ifnum #2>\c@secnumdepth\else#1 \csname the#1\endcsname\fi}
  \spel@idxwrite{\spel@@label}{\spel@@optpart\thesubparagraph}%
  \spel@chunkwrite{\spel@@optpart\thesubparagraph}{#8}%
}
\fi
\ifspel@disabled\else
\let\spel@@ssect\@ssect
\def\@ssect#1#2#3#4#5{%
  \stepcounter{spel@ssect}%
  %\setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@ssect{#1}{#2}{#3}{#4}{%
    \href{run:\audiodir/\spel@@optpart\thesubparagraph-star-\thespel@ssect.\spel@format}%
         {#5}}%
  \spel@idxwrite{section}{\spel@@optpart\thesubparagraph-star-\thespel@ssect}%
  \spel@chunkwrite{\spel@@optpart\thesubparagraph-star-\thespel@ssect}{#5}%
}
\fi
\ifspel@disabled\else
\let\spel@@fntext\@footnotetext
\long\def\@footnotetext#1{%
  \stepcounter{spel@footnote}%
  \settowidth\spel@mptboxwidth{\usebox\spel@mptbox}%
  \spel@@fntext{%
    \hspace*{-\spel@mptboxwidth}\href{run:\audiodir/footnote-\thespel@footnote.\spel@format}{\usebox\spel@mptbox}#1}%
  \spel@idxwrite{footnote}{footnote-\thespel@footnote}%
  \spel@chunkwrite{footnote-\thespel@footnote}{#1}%
}
\fi

\ifspel@disabled\newcommand{\spelitem}{\item}\else
\newcommand{\spelitem}{%
  \@ifnextchar[{\spelitem@opt}{\spelitem@intone}
}
\fi
\def\spelitem@opt[#1]{\spelitem@inttwo{#1}}
\def\spelitem@intone#1{%
  \stepcounter{spel@chunk}%
  \settowidth\spel@mptboxwidth{\usebox\spel@mptbox}%
  \spel@idxwrite{item}{\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \spel@chunkwrite{\spel@@optpart\thesubparagraph-\thespel@chunk}{#1}%
  \item \hspace*{-\spel@mptboxwidth}\href{run:\audiodir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}{\usebox\spel@mptbox}#1}
\def\spelitem@inttwo#1#2{%
  \stepcounter{spel@chunk}%
  \settowidth\spel@mptboxwidth{\usebox\spel@mptbox}%
  \spel@idxwrite{item}{\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \spel@chunkwrite{\spel@@optpart\thesubparagraph-\thespel@chunk}{#1 . #2}%
\item[#1] \hspace*{-\spel@mptboxwidth}\href{run:\audiodir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}{\usebox\spel@mptbox}#2}
\ifspel@disabled\else
\let\spel@@caption\caption
\renewcommand\caption[2][]{%
  \stepcounter{spel@chunk}%
  \spel@idxwrite{caption}{\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \spel@chunkwrite{\spel@@optpart\thesubparagraph-\thespel@chunk}{#2}%
  \spel@@caption[#1]{\protect\href{run:\audiodir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}{#2}}
}
\fi
\newlength\spel@mptboxwidth
\newsavebox\spel@mptbox
\savebox\spel@mptbox{\textcolor{black!25}{$\qquad$}}
\newif\ifspel@chunkarealink
\define@key{spelchunk}{arealink}[]{\spel@chunkarealinktrue}
\ifspel@disabled\def\spelchunk{}\else
\def\spelchunk{%
  \catcode`\^^M=\active%
  \stepcounter{spel@chunk}%
  \spel@idxwrite{chunk}{\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \@ifnextchar[{\catcode`\^^M=5\spelchunk@opt}{\catcode`\^^M=5\spelchunk@int}}%
\fi
\ifspel@disabled\def\endspelchunk{}\else
\def\endspelchunk{%
  \end{VerbatimOut}%
  \catcode`\^^M=5\relax%
  \ifspel@chunkarealink%
  \href{run:\audiodir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}{\input{./\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk}}%
  \else%
  \settowidth\spel@mptboxwidth{\usebox\spel@mptbox}%
  \hspace*{-\spel@mptboxwidth}\href{run:\audiodir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}{\usebox\spel@mptbox}\input{./\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \fi%
  \spel@chunkarealinkfalse%
}%
\fi
\def\spelchunk@opt[#1]{\setkeys{spelchunk}{#1}\spelchunk@int}
\def\spelchunk@int{%
  \VerbatimEnvironment
  \begin{VerbatimOut}{\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk.tex}}
\def\spelchunkad{%
  \catcode`\^^M=\active
  \@ifnextchar[{\catcode`\^^M=5\spelchunk@opt}{\catcode`\^^M=5\spelchunk@int}}
\def\endspelchunkad{%
  \end{VerbatimOut}
  \catcode`\^^M=5\relax
}
\AtBeginDocument{
  \newcommand\spel@@optpart{}
}
\ExplSyntaxOn
\NewDocumentCommand{\spelmacpp}{moom}
{
  \addtostream{spelidx}{macpp|#1|#2|#3|#4}
}
\ExplSyntaxOff
\spelmacpp{sf}{}
\spelmacpp{it}{}
\spelmacpp{tt}{}
\spelmacpp{bf}{}
\spelmacpp{HUGE}{}
\spelmacpp{Huge}{}
\spelmacpp{huge}{}
\spelmacpp{LARGE}{}
\spelmacpp{Large}{}
\spelmacpp{large}{}
\spelmacpp{normalsize}{}
\spelmacpp{small}{}
\spelmacpp{footnotesize}{}
\spelmacpp{scriptsize}{}
\spelmacpp{tiny}{}
\spelmacpp{minuscule}{}
\spelmacpp{textsf}[1]{keep}
\spelmacpp{textit}[1]{keep}
\spelmacpp{texttt}[1]{keep}
\spelmacpp{textbf}[1]{keep}
\spelmacpp{quad}{}
\spelmacpp{qquad}{}
\spelmacpp{displaystyle}{}
\spelmacpp{relax}{}
\spelmacpp{strut}{}
\spelmacpp{mathstrut}{}
\spelmacpp{label}[1]{}
\spelmacpp{fbox}[1]{keep}
\ExplSyntaxOn
\NewDocumentCommand{\spelenvpp}{moom}
{
  \addtostream{spelidx}{envpp|#1|#2|#3|#4}
}
\ExplSyntaxOff
\spelenvpp{center}{keep}
\ExplSyntaxOn
\NewDocumentCommand{\spelmacad}{moom}
{
  \addtostream{spelidx}{macad|#1|#2|#3|#4}
}
\ExplSyntaxOff
\spelmacad{spelatex}{spee-lay-tech}
\spelmacad{spelbox}{spel-box}
\spelmacad{spelpl}{spel wizzard dot pl}
\spelmacad{LaTeX}{lay-tech}
\spelmacad{TeX}{tech}
\spelmacad{textsf}[1]{#1}
\spelmacad{texttt}[1]{#1}
\spelmacad{textit}[1]{#1}
\spelmacad{emph}[1]{#1}
\spelmacad{underline}[1]{#1}
\spelmacad{mbox}[1]{#1}
\spelmacad{text}[1]{#1}
\spelmacad{nobreakspace}{#1}
\spelmacad{textasciitilde}[1]{ }
\spelmacad{textbackslash}{backslash}
\spelmacad{footnote}[1]{}
\spelmacad{pm}{@{i18n(plusminus)}}
\spelmacad{ldots}{...}
\spelmacad{cite}[1]{}
\spelmacad{ref}[1]{}
\spelmacad{pageref}[1]{}
\ExplSyntaxOn
\NewDocumentCommand{\spelenvad}{moomm}
{
  \addtostream{spelidx}{envad|#1|#2|#3|#4|#5}
}
\ExplSyntaxOff
\spelenvad{center}{}{}
\ifspel@extramath
\DeclareRobustCommand{\setenum}[1]{\left\{#1\right\}}
\spelmacad{setenum}[1]{@{i18n(Setenum,#1)}}
\DeclareRobustCommand{\setdesc}[1]{\left\{#1\right\}}
\spelmacad{setdesc}[1]{@{i18n(Setdesc,#1)}}
\fi
\endinput
%%
%% End of file `spelatex.sty'.
