% \iffalse meta-comment
%
% Copyright (C) 2025-2026 by Walter Daems <walter.daems@uantwerpen.be>
%                   and Paul Levrie
%
% This work 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.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Walter Daems.
%
% This work consists of the files spelatex.dtx, spelatex.ins, 
% and any derivative file, generated from the dtx file using
% the ins driver file.
% \fi
%
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{spelatex}
%</package>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{spelatex.dtx}
%</driver>
%<*package>
   [2026-04-09 v0.96 SpeLaTeX]
%</package>
\def\fileversion{v0.96}
\def\filedate{2026-04-09}
%<*driver> 
\documentclass[11pt,a4paper]{ltxdoc}
\usepackage[margin=1in,left=2in]{geometry}
\usepackage{makeidx}
\usepackage{alltt}
\usepackage[english]{babel}
\usepackage[extramath,
            server=https://ctan.org/tex-archive/macros/latex/contrib/spelatex
           ]{spelatex}
\usepackage[overload]{empheq}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{tikz}
\IfFileExists{tocbibind.sty}{\usepackage{tocbibind}}{}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\StopEventually{\PrintChanges\PrintIndex}
\spelmacad{DescribeEnv}[1]{#1}
\spelmacad{DescribeMacro}[1]{#1}
\def\MacroFont{\footnotesize
  \usefont\encodingdefault
  \ttdefault
  \mddefault
  \shapedefault
}%
\begin{document}
 \DocInput{spelatex.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.90}{2024/05/31}{. Birth}
% \changes{v0.91}{2024/06/21}{. First overhaul:\\
%                               - avoided big active link areas\\
%                               - sketched bigger picture, leading to
%                               the three project phases.}
% \changes{v0.92}{2024/09/09}{. Second overhaul:\\
%                               - dumped orgmode export idea (too small of an audience)\\
%                               - introduced markers for non-area-links\\
%                               - implemented audio on server\\
%                               - implemented <\kern-0.5ex<\kern-0.5ex<-macro as a shorthand}
% \changes{v0.93}{2024/10/23}{. Major overhaul:\\
%                               - improvements to allow for TeX-ing of full course of Walter\\
%                               - introduced shorthand macro \textbackslash<<<\\
%                               - switching between math and text mode fixed}
% \changes{v0.94}{2024/11/01}{. Bug fixes for TUGboat article\\
%                               - removed all 'dropped character warnings'\\
%                               - the logo now has a hyphenation point\\
%                               - increased font size of documentation}
% \changes{v0.94b}{2024/11/04}{. Fixed bug that resulted in duplicate text}
% \changes{v0.95}{2025/01/31}{. Fine tuning of some details as suggested by Karl Berry\\
%                               - now preserving user's hyperlink formatting\\
%                               - corrected various spacing/alignment details\\
%                               - explored using existing hook infrastructure (not succesful)}
% \changes{v0.96}{2026/04/09}{. Adding some missing features\\
%                               - spelitemcont to allow for continuation of itemization
%                                 after intermission by a display item}
% 
% \GetFileInfo{spelatex.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% \setlength{\parindent}{0em}
% \addtolength{\parskip}{0.5\baselineskip}
% \setlength\IndexMin{200pt}
%
% \title{\sf \spelatex{} --- Speech-enabled \LaTeX{}}
% \author{Walter Daems (\texttt{walter.daems@uantwerpen.be})
%         and Paul Levrie}
% \date{\fileversion --- \filedate}
%
% \newrobustcmd\GNU{GNU}
% \spelmacad{GNU}{gnew}
% \newrobustcmd\TexLive{Tex Live}
% \spelmacad{TexLive}{tech-laaiv}
% \newrobustcmd\MikTeX{MikTeX}
% \spelmacad{MikTeX}{miktech}
% \newrobustcmd\CTAN{CTAN}
% \spelmacad{CTAN}{see-tan}
% \newrobustcmd\CPAN{CPAN}
% \spelmacad{CPAN}{see-pan}
% \newrobustcmd\POD{POD}
% \spelmacad{POD}{pod}
%
% \maketitle
% \fvset{gobble=2}
%
% \section*{Disclaimer}
% \<<<{
%   Note that this is an experimental package. Its interface may change
%   considerably over subsequent versions (until v1.0).
% }
%
% \section{Preface}
%
% \subsection{Background}
% 
% \<<<{
%   At our institute, the University of Antwerp in Belgium, the number
%   of students with reading and/or writing disorders (or at least
%   aware of these disorders)  is increasing. Approximately 5\% of the
%   students are registered with such a disorder and the number is rising
%   steadily over the past 10 years. Probably this number is an
%   underestimation as a number of people opt not to register their
%   disorder. 
% }

% \<<<{
%   A large portion of the study materials we offer to students is
%   still written material. The authors believe that this will keep on
%   being so, even given the multimedia and AI options that have
%   become mainstream. Let's not go into this debate for now.\\
%   However, written course texts cannot be but suboptimal for
%   students with reading disorders.
% }
%
% \<<<{
%   For small texts, reading them out loud and recording them using a
%   voice recorder to create an aid for our target group, is still
%   feasible. We have taken that in the past for exam 
%   assignments. However, for bigger texts (like course syllabi) this
%   is beyond the time a professor can afford spending on this small a
%   group of students. Yes, economic laws also govern teaching!
% }
%
% \subsection{State of the art}
%
% \subsubsection{In general}
%
% \<<<{
%   Therefore, reverting to readily available text-to-speech software
%   is an obvious choice. Nowadays, special software exists that
%   provides the functionality of reading out loud the contents of
%   electronic documents, e.g. NVDA \cite{NVDA} or
%   SprintPlus~\cite{SPRINT}. Moreover, more and more standard PDF
%   readers (such  
%   as Acrobat Reader~\cite{ADOBEREADER} have the facility of
%   performing text-to-speech). For nontechnical subjects, this works
%   fine. However, when it comes to technical course syllabi that are
%   loaded with non-trivial mathematics, the standard text-to-speech
%   packages fail to meet our expectations. In  addition, they cannot
%   read a sensible textual description of figures or tables.
% }
%
% \<<<{
%   The issue with reading mathematics will be solved in the future,
%   by enforcing mathematical equations to follow a specific standard
%   that can be parsed and converted, not only into a visual
%   representation, but also into proper text. MathML will be one of
%   the candidates for that format.
% }
%
% \<<<{
%   The issue with figures and tables can be solved by using the tag
%   infrastructure of PDF. The format provides a system of tags that
%   allow you to provide extra information about the content of a
%   document, in much the same way as you can specify an 'alt' key for
%   an image in HTML. This tag could contain a proper textual
%   description of the figure or the table.
% }
%
% \subsubsection{For \LaTeX}
%
% \<<<{
%   Currently, the \LaTeX{} project is investing in enabling \LaTeX{} to
%   partially automate the tagging of PDFs with the \texttt{tagpdf}
%   package~\cite{TAGPDF}, such that the user only has to do a minimal
%   job (adding tags for figures and tables). The goal is to maximize
%   the accessibility of \LaTeX-produced documents.
% } 
%
% \<<<{
%   So all is well? Not quite. Though we are confident that --- with enough
%   time --- the community will solve the issue completely, there are
%   still some gaps:
% }
% \begin{itemize}
% \spelitem{The tagpdf package is still not a part of the mainstream
% \LaTeX{}-kernel.}
% \spelitem{MathML reading support in PDF readers is still in its
% infancy.}
% \spelitem{Many PDF readers do not fully support tags yet.}
% \end{itemize}
%
% \subsection{This package}
%
% \<<<{
%   This package aims to overcome these problems in the meantime and
%   also to contribute to the longterm goal: making perfectly tagged
%   PDFs that are read by any PDF-reader.
% }
%
% \<<<{
%   In the \emph{first phase} of this package (i.e. the version you are
%   looking at right now), this package reads your \LaTeX{} source,
%   converts the text and the formulas to audio files and equips your
%   PDF with hyperlinks to these files, such that with a few clicks
%   you can listen to your document.
%   The audio files are external files that should be packaged with
%   your PDF to allow a reader to use the document with the available
%   audio.
%   You have the choice to use local files or files that are made available on a
%   server (as holds for this text; the audio files are on the CTAN servers).\\
%   How does \spelatex{} read the formulas? It parses your \LaTeX{} constructs and
%   makes the best of it. This will probably be the part that might
%   survive up until the very last phase of this package.
% }
%
% \<<<{
%   In a \emph{second phase} of this package, the audio files will be embedded
%   into the PDF. Currently, there are not enough PDF readers that
%   support this feature. Therefore, we decided to keep using the
%   external audio files for now.
% }
%
% \<<<{
%   In a \emph{third phase}, the audio files \emph{may be} abandoned
%   alltogether, fully switching to tags. And we do think that this
%   should be the end goal. The reasons why we say
%   \emph{'may be'}, are:
% }
% \begin{itemize}
% \spelitem{The voices of the current PDF-readers are still not of the
% same quality as the ones available online. And quality does matter.}
% \spelitem{The better voices may require cloud access, and probably
% will not be free, therefore (us) paying for them at document creation
% time, makes more sense to us than having our students pay
% for these voices whenever they read the document.}
% \spelitem{The industry standard Adobe reader is not easily available
% on open-source operating systems (like UNIX/BSD/Linux-derived
% platforms). You might consider using emulation using
% wine~\cite{WINE}, but in that case  you can forget about audio. Free
% access to software is something we consider to be a must-have,
% rather than a nice-to-have.}
% \end{itemize}
%
% \<<<{
%   Will \spelatex{} become obsolete in the future?
%   Undoubtedly so. But for the time being, it answers our desire to
%   provide our students with good audio support when studying their
%   engineering courses. That is now, not only in five years time.
% }

% \<<<{
%   We hope that you enjoy
%   using our software, or that --- if you are not pleased with it ---
%   it triggers you to give us feedback or to come up with a better
%   solution. We especially would like to thank Ulrike Fischer (of the
%   \LaTeX-project and the maintainer of the tagpdf package) for
%   trying to use this package and reaching out to give us feedback.
%   One of her suggestions (not to use big hyperlink-areas) was almost
%   instantly implemented and has been adopted as the standard way of
%   linking.
% }
%
% \<<<{
%   You are free to use our software but kindly ask you to provide a
%   mention ``The audio materials of this text have been prepared with
%   \spelatex{}'' in the section treating copyrights,
%   bibliographic data or any other spot of your text that is
%   suited. We'd also welcome a short mail of yours telling that you
%   make use of the package. The pleasure of receiving such an e-mail
%   makes our day. 
% }
%
% \<<<{
%   You are free to modify this \LaTeX-package, keeping a reference to
%   our original package intact, provided that your package is subject
%   to the LPPL license, as is \spelatex{}. However, contributing to our
%   package or to the \LaTeX{} project in general, might be a better
%   way to go, in order to bundle the efforts 
%   for a better speech-enabled \LaTeX{}.
% }
%
% \section{Introduction}
%
% \subsection{Target audience}
% \<<<{
%   \spelatex{} is primarily intended for persons with a reading
%   disorder. This may be:
% }
% \begin{itemize}
%   \spelitem{persons suffering dyslexia}
%   \spelitem{visually impaired persons}
%    \begin{itemize}
%      \spelitem{persons who still can recognize the basic
%      parts of a book,
%        i.e. are able to operate a PDF viewer and click on the
%        individual parts.}
%      \spelitem{persons who can't recognize the basic parts of a book
%      (e.g., blind persons): they can listen to the automatic
%      playback of the ordered chain of audio fragments.}
%    \end{itemize}
% \end{itemize}
%
% \<<<{
%   But also people who want to multitask, e.g., gardening while
%   listening to a technical book, can benefit from
%   \spelatex{}.\footnote{Note that multitasking is not reserved for persons
%   without visual impairment. Also visually impaired persons can
%   benefit from listening to an audiobook while doing other
%   things.}\\ We often use \spelatex{} to proofread the texts we've
%   written ourselves as we hear language errors more easily than we
%   spot them while reading. 
% }
% 
% \subsection{The magic under the hood}
%
% \subsubsection{The overall picture}
%
% \<<<{
% \spelatex{} equips the PDF that is generated by \LaTeX{}
% with hyperlinks to audio files that contain the spoken
% equivalent of the original text, equations, figures and tables.
% }
% \spelmacpp{figref}[1]{Fig.~\ref{#1}}
% \newcommand\figref[1]{Fig.~\ref{#1}}  
% \begin{spelchunk}
%   Let's start by considering the flow depicted in
%   Fig.~\ref{fig:setup} at the top of the diagram. \figref{fig:setup}
%   By loading the |spel.sty| package in  your source
%   document (|text.tex|), \LaTeX{} will produce a PDF file that references audio
%   files that will be generated later (see below). In
%   addition, it generates text chunks (i.e. small portions of
%   your text) in separate files (|.tex|) and a spel index file
%   (|.spelidx|) referencing them in sequence.
% \end{spelchunk}
% 
% \<<<{
%   Together with the |.aux|-file (needed by \spelatex{} for labels and
%   citations), these are the inputs to the \spelatex-engine (|spel-wizard.pl|)
%   that parses the text chunks, writes a full text version of them as
%   spel files (with extension |.spel|) and 
%   controls the text-to-speech engine to generate audio versions of
%   them.\footnote{In the figure, Ogg Vorbis has been chosen as
%   format, but this can be any audio format.}
% }
% 
% \<<<{
%   To avoid excessive text to speech conversion (i.e. an expensive step)
%   the \spelatex{} engine derives an MD5 fingerprint of them and compares it
%   to previously generated fingerprints for the chunk. If the
%   fingerprint has changed, the audio file is overwritten (or
%   created the first time), otherwise it is left untouched.
% }
% 
% \<<<{
%   As a cherry on top, the \spelatex-engine also creates a top-level playlist,
%   such that you may use the audio files for a \POD{}cast-like
%   listening experience.\\
%   Something that has not been indicated on the figure, is that for
%   reading out loud entire (sub)sections, the PDF-file also references
%   m3u playlists that gather all chunks belonging to the (sub)section.
% }
%
% \begin{figure}
%   \begin{spelchunk}
%     \begin{center}
%       \begin{tikzpicture}
%       [scale=0.8,>=latex,
%       doc/.style={rectangle,fill=black!10,align=center,minimum
%       width=2cm,minimum height=2cm},
%       tool/.style={rectangle,draw,align=center}]
%       \node [doc] (text) at (0,3) {text.tex\\\footnotesize(source file)};
%       \node [doc] (R) at (-3,0) {spel.sty\\\footnotesize(package)};
%       \node [tool] (latex) at (0,0) {\LaTeX\\\footnotesize(compiler)};
%       \node [doc] (pdf) at (0,-3) {text.pdf\\\footnotesize(PDF with\\\footnotesize hyperlinks)};
%       \node [doc] (spelidx) at (6,-3) {text.spelidx\\\footnotesize(index file)};
%       \node [doc] (aux) at (9,-3) {text.aux\\\footnotesize(auxiliary file)};
%       \node [doc] (files) at (3,-3) {*.tex\\\footnotesize(text chunks)};
%       \draw[->] (text) -- (latex);
%       \draw[->,dotted] (text) -- (R);
%       \draw[->,dotted] (spelidx) -- (files);
%       \draw[->] (R) -- (latex);
%       \draw[->] (latex) -- (pdf);
%       \draw[->] (latex) edge[out=0,in=90] (spelidx);
%       \draw[->] (latex) edge[out=10,in=90] (aux);
%       \draw[->] (latex) edge[out=-10,in=90] (files);
%       \node [tool] (engine) at (6,-6) {\spelpl{}\\
%       \footnotesize(\spelatex{} engine)};
%       \node [tool] (t2s) at (1.5,-6) {text-to-speech\\engine};
%       \draw[->] (files) -- (engine);
%       \draw[->] (spelidx) -- (engine);
%       \draw[->] (aux) -- (engine);
%       \node[doc] (ogg) at (0,-9) {*.ogg\\\footnotesize(audio files)};
%       \node[doc] (spel) at (3,-9) {*.spel\\\footnotesize(spel files)};
%       \node[doc] (m3u) at (6,-9) {text.m3u\\\footnotesize(playlist)};
%       \node[doc] (md5) at (9,-9) {*.md5\\\footnotesize(fingerprints)};
%       \draw[->] (engine) -- (spel);
%       \draw[->] (engine) -- (m3u);
%       \draw[<->] (engine) -- (md5);
%       \draw[->,dotted] (pdf) edge[out=-115,in=115] (ogg);
%       \draw[->,dotted] (m3u) edge[out=-125,in=-55] (ogg);
%       \draw[->,dashed] (engine) -- (t2s);
%       \draw[->] (spel) -- (t2s);
%       \draw[->] (t2s) -- (ogg);
%       \end{tikzpicture}
%     \end{center}
%   \end{spelchunk}
%   \begin{spelchunkad}
%     If you load the \spelatex{} style file in your source file (at the
%     top of the figure) and prepare your source file according to the
%     instructions in this manual, than
%     your compiler will generate a PDF file with hyperlinks, a
%     dot aawks-file and a dot spellindex-file together with a directory full of
%     dot tex files containing the text chunks to be processed by the
%     \spelpl-engine. This is a perl script that converts the chunks into
%     plain text readable spel files. The script is called spel dash
%     wizard dot pl. It also creates a playlist and  audio files using a
%     text-to-speech engine. In this case, these are 
%     Ogg-Vorbis files. To avoid having to call the text-to-speech
%     engine too frequently (which may incur costs), MD5 fingerprints
%     are used such that chunks that have been generated before and
%     are unchanged, can be reused. The end result is a PDF file that
%     references the audio files.
%   \end{spelchunkad}
%   \spelcaption{Basic tool setup of the \spelatex{} package; filled boxes indicate
%   files, outlined boxes indicate tools; solid lines indicates use or
%   creation of files, dotted lines indicate references, dashed lines
%   indicate a control relationship.}
%   \label{fig:setup}
% \end{figure}
%
% \<<<{
% You might wonder: where are the links? Well, there are three
% variants:
% }
% \begin{itemize}
%   \spelitem{\emph{area links}, which are almost exclusively
%   used for equations, tables or figures. These links make an entire
%   rectangle active, linking to the corresponding audio file.}
%   \spelitem{\emph{group links}, indicated by small right-pointing
%   triangles next to section headers (on the far right). These cause all
%   blocks in the section to be read one by one.\\
%   In case you specify the
%   package option \texttt{markervisibility=none} these triangles will become
%   invisible. However, the clickable areay still exists. Try!} 
%   \spelitem{\emph{chunk links}, before every
%   paragraph, footnote or list, a small triangle indicates a clickable link.\\
%   If you activate the package option \texttt{markervisibility=onlygroups}, they will
%   become invisible, but still clickable. Try it! Once you
%   are aware that these regions are active, you'll find them
%   easily. Not using the full paragraph as an active
%   region, allows existing hyperlinks (like for citations, references
%   or URLs) to still function.}
% \end{itemize}
%
%
% \subsubsection{Implicit spelchunks}
% \spelmacad{usepackage}[1]{the usepackage #1 macro}
% \spelmacad{title}{the title macro}
% \spelmacad{author}{the author macro}
% \spelmacad{section}{the section macro}
% \spelmacad{caption}{the caption macro}
% \spelmacad{footnote}{the footnote macro}
% \spelmacad{thanks}{the thanks macro}
% \spelmacad{item}{the item macro}
% \spelmacad{spelitem}{the spelitem macro}
% \<<<{
%   Generating the text chunks to be read out loud requires us to use
%   special \LaTeX-macros. For all pieces of text that are within
%   an existing macro (e.g. |\title|, |\author|, |\section|,
%   |\footnote|, |\thanks|), these macros have been
%   redefined by the \spelatex{}-package to 
%   execute the magic without any further hassle.\\
%   We call these \LaTeX-fragments \emph{implicit spelchunks}.%
% }
%
% \<<<{
%   However, not all \LaTeX-constructs can be dealt with in an
%   automatic way. This is true for any |\item| you put inside a list.
%   You need to replace that with a |\spelitem| that takes the text
%   that follows as a first explicit argument, i.e. |\item blabla|
%   should be replaced by |\spelitem{blabla}|.
%   The same holds for any |\caption|. Too many packages (like
%   subcaption/subfigure) redefine captions, so I chose to stay out of
%   their way. Therefore every |\caption| must be replaced by a
%   |\spelcaption|.
% }
% \<<<{
%   We call these \LaTeX-fragments \emph{defunct implicit
%   spelchunks}. They should have been implicit, but we could not get
%   that to work without problems. Therefore you need to mark them
%   explicitly as |\spelitem| constructs.
% }
%
% \subsubsection{Explicit spelchunks}
% \<<<{
%   One would hope that displaymath environments are also implicit
%   spelchunks. However, overriding environments in \LaTeX{} is a tricky
%   business. In view of this, the \spelatex{} package keeps away from
%   this, and we've chosen to treat displaymath environments (like
%   |equation|, |eqnarray|, |gather|, |align|, |alignat|) the same way
%   as tables or figures, i.e. you need to embed the in a |spelchunk|
%   environment. The only difference between math environments and
%   figures an tables is that displaymath environments can be
%   automatically read out loud by the \spelpl{} script, while you
%   will have to provide a text description for tables and figures
%   manually, using a subsequence |spelchunkad| 
%   environment (the suffix ad stands for \emph{audio description}).
% }
%
% \<<<{
%   To keep the terminology clear, we label them as automatic
%   and manual explicit spelchunks respectively:
% }
% \begin{itemize}
% \spelitem{automatic: \texttt{equation}, \texttt{eqnarray},
% \texttt{gather}, \texttt{align}, \texttt{alignat}, \ldots} 
% \spelitem{manual: \texttt{figure}, \texttt{table},
% \texttt{tikzpicture}, \ldots} 
% \end{itemize}
%
% \<<<{
%   The similarity between both categories is that you both embed them
%   in a |spelchunk| environment, but that you provide the manual
%   textual description using a |spelchunkad| environment right after
%   the chunk for the manual ones: in this way, the |spelchunkad| environment provides an
%   alternative text for the chunk. Note that this way of working also
%   enables you to provide an overriding text for an automatic spelchunk,
%   e.g., an equation, if you
%   think that \spelpl{} is doing a bad job. You do us a favor if
%   you submit this subpar behavior as a bug report to us!
% }
%
% \<<<{
%   It is worthwile to make good descriptions for a figure or a
%   table. It's here that you can create true added value to your
%   manuscript, even for readers without impairment!
% }
% 
% \subsubsection{Paragraphs}
% \<<<{
%   However, there is the elephant in the room that we did not yet
%   talk about, the paragraph. Indeed, it is desirable to split plain
%   text according to the paragraphs in the document. Alas, paragraphs
%   are one of the silent features that are 
%   not easily accessible from within a \LaTeX-package.
%   Therefore paragraphs (or smaller text chunks) are considered to be
%   explicit spelchunks and need to be embedded
%   in |spelchunk| environments. This environment will cause its
%   contents to be hyperlinked to a separate piece of audio.
% }
%
% \<<<{
%   Encasing all your paragraphs with |spelchunk| environments
%   manually is a pain. There is a reason why in \LaTeX{} 
%   paragraphs can be created by a double newline: convenience.
%   The |spelchunk|-environment encasing ruins this totally!
% }
% \spelmacad{<<<}{the shorthand macro}
% \<<<{
%   To ease the pain and in order to avoid the visual intrusiveness of the
%   spelchunk environments, you can also use the \texttt{\textbackslash{}<<<\{\}} command to
%   encase your paragraphs. In some cases the \texttt{\textbackslash{}<<<\{\}}
%   command will not work, e.g., if there is a |Verbatim| environment
%   inside. In that case  you must use the |spelchunk| environment directly.
% }
%
% \subsection{Extra math commands}
%
% \<<<{
% Some of the ways to specify mathematical expressions in \LaTeX{} is
% very liberal, what makes converting them to text quite
% difficult. Therefore, we also provide some
% extra constructs that make life easier for both parties: you as a
% user and \spelpl{} as a parser.
% }
%
% \<<<{
%   An example of this are sets. We provide two commands to define a 
%   set. As we want these commands to blend in with general \LaTeX{},
%   we did not equip them with a prefix |spel|. Therefore, we made
%   activating them conditional to specifying the package option
%   |extramath|.
% }
% \begin{description}
% \spelitem[\texttt{\textbackslash{}setenum}]{a command to define a set
% that consists of comma or semicolon separated elements}
% \spelitem[\texttt{\textbackslash{}setdesc}]{a command to define a
% set that is specified using a description}
% \end{description}
%
%
% \subsection{Added value}
%
% \<<<{
% Why would it make sense to use \spelatex? We think there are many
% selling points. We can mention a few:
% }
% \begin{description}
%   \spelitem[Free for the content provider]{
%     If you are using a freeware text-to-speech engine (like for
%     example festival \cite{FESTIVAL} or balabolka \cite{BALABOLKA})
%     and a royalty-free audio format and player (like for example
%     ogg-vorbis), generating audio-enabled documents only requires
%     the effort of preparing your manuscript. There are no license
%     costs involved.\\
%     You could also consider to use an online paying text-to-speech
%     service. As an example, we incorporated a connection to Amazon's
%     Polly \cite{AWSPOLLY}. We admit, it's not free, but it doesn't
%     cost an arm and a leg either.\\
%     In addition, if your user has a better-quality (maybe
%     commercial) text-to-speech system, he/she can reconvert the text
%     files him-/herself, equiping your document with a voice they
%     like and are used to, without you having to worry about license
%     costs. They might even use an AI-generated copy of their own
%     voice!}
%   \spelitem[Free for your audience]{
%     In addition, the user of your audio-enabled document doesn't
%     need to buy a license for text-to-speech software. Only a PDF-viewer
%     and a standard audio-player program are required.}
%   \spelitem[Math capable]{
%     Try some of the equations in this manuscript in
%     section~\ref{sec:demo}. We are quite confident you'll be
%     convinced fairly soon.} 
% \end{description}
%
% \section{Installation}
%
% \subsection{The \spelatex{} package}
% \<<<{
%   If you are a package manager then you'll know how to
%   prepare an installation package for \spelatex.
% }
%
% \<<<{
%   If you are a normal user, check if there is a package that your
%   favorite \LaTeX{} distributor has prepared for you. Most of the
%   major distributions (like e.g. \TexLive{} or \MikTeX{}) do so.\\
%   The fallback option is to grab the |spelatex.sty| file from CTAN
%   and put it in our \TeX{} search path.
% }
%
% \<<<{
%   The \spelatex{} package uses a number of auxiliary packages, fetch them
%   from \CTAN{} \cite{CTAN} if your \TeX{} distributor does not provide
%   them. The ones used are: |expl3|, |hyperref|, |xcolor|, |ifthen|, |verbatim|,
%   |fancyvrb|, |newfile|, |rotating|, |babel|, |kvoptions| and |xkeyval|.
% }
%
% \subsection{The \spelpl{} speech generator}
%
% \subsubsection{The script}
% \<<<{
%   You can install the wizard assuming you have a working Perl
%   interpreter installed. Assuming you're on \GNU/Linux or MAC, you
%   should be able to find an installation package using the package
%   manager for your distribution. If you are on MS-Windows, look for
%   Strawberry perl or ActiveState perl.
% }
%
% \<<<{
%   The only thing to do is to install the |SpeL::Wizard|
%   module. You can do this with the perl pacakge manager for your
%   interpreter.
% }
%
% \<<<{
%   Open a terminal or command window, and then enter on the
%   command line (the dollar represents your prompt):
% }
%
% \<<<{
%   On \GNU/Linux and MAC: |$ cpanm SpeL::Wizard|\\
%   For Strawberry perl: |$ cpan SpeL::Wizard|\\
%   For ActiveState perl: |$ ppm install SpeL-Wizard|
% }
%
% \<<<{
%   The script \spelpl{} will be installed on your system. Make sure
%   it is on your search path.
% }
%
% \subsubsection{The configuration file}
%
% \begin{spelchunk}
% Finally, you need to provide \spelpl{} with an appropriate
% config-file, named |tts.conf| that sets up the text-to-speech conversion.
% Below you can find a setup for Festival \cite{FESTIVAL}:
% \begin{Verbatim}
%   [engine]
%   tts=festival
%   
%   [languagetags]
%   dutch=nl
%   english=en-gb
%
%   [voices]
%   dutch=nl1_mbrola
%   english=en1_mbrola
% \end{Verbatim}
% \end{spelchunk}
%
% \begin{spelchunk}
% And additionally, for the Microsoft users a setup for Balabolka \cite{BALABOLKA}:
% \begin{Verbatim}
%   [engine]
%   tts=balabolka
%   
%   [languagetags]
%   english=en-us
%
%   [voices]
%   english=Zira
% \end{Verbatim}
% \end{spelchunk}
%
% \<<<{
% The tts configuration parameter defines the speech engine to use.
% The languagetags section defines how the babel languages are mapped to
% internationalization codes (also known as locales).
% The voices section specifies what voice to use for a specific language.
% }
% 
% \begin{spelchunk}
% An environment variable can specify where your config file is
% located, e.g., on \GNU/Linux:
% \begin{Verbatim}
%   $ export SPELWIZARD_CONFIG=/home/wdaems/.config/tts.conf
% \end{Verbatim}
% \end{spelchunk}
% \begin{spelchunk}
%   If that variable is not set, the script will look in a subdirectory
%   |.spel_wizard| of your home-folder (or |%userprofile%| on
%   MS-Windows), or it will take the default that came with the
%   |SpeL::Wizard| module.
% \end{spelchunk}
%
% \<<<{
%   Be aware that you need to install your text-to-speech tool yourself
%   according to the documentation provided by the tool provider.
%   In addition, make sure it the executable is in your search path. In
%   case you are using an online text-to-speech service provider you
%   will need to get an account on their cloud platform and setup
%   credentials and whatever is needed to get going. Providing
%   assistance for this is beyond the aim of this manual.
% }
%
% \subsection{The PDF viewer}
%
% \<<<{
%   You need to make sure you have a PDF-viewer that supports file links
%   E.g., xpdf \cite{XPDF} does not, but evince \cite{EVINCE}, okular
%   \cite{OKULAR} and Adobe Reader \cite{ADOBEREADER} do.
% }
%
% \subsection{The media player}
%
% \<<<{
%   When clicking a \spelatex-enabled item in your PDF-file, your media
%   player is started to play the |.ogg| or |.m3u|-file. On GNU/Linux
%   most media players work fine (SoX, totem, vlc, \ldots).
% }
%
% \<<<{
%   On windows, we recommend using vlc. It works out of the box.
%   When using the stock Windows Media Player, you will need to add
%   every folder that contains a PDF you'd like to have read, to your
%   Media Player library. Search the internet to find instructions on
%   that and be prepared: in line with Microsoft's standard practice it
%   is well hidden in the interface.
% }
%
% \<<<{
%   If you gave the |server| option to the \spelatex{} package, then your
%   favorite webbrowser will be started to download and play the file.
%   If you move it out of your way, you can avoid that it jumps in front of
%   your text every time again.
% }
%
% \section{Usage}
%
% \subsection{Preparing your document source}
% \begin{spelchunk}
%   Using the \spelatex{} package is very simple. Just load the package's
%   style file using an appropriate |\usepackage{spelatex}|.
% \end{spelchunk}
%
% \<<<{
%   There are $5$ things to do:
% }
% \begin{enumerate}
%   \spelitem{Treat the defunct implicit spelchunks.}
%   \spelitem{Treat the explicit spelchunks.}
%   \spelitem{Manually provide text to read when needed.}
%   \spelitem{Provide audiodescriptions or preprocessing instructions
%   for your typesetting macros.} 
%   \spelitem{Provide audiodescriptions or preprocessing instructions
%   for your typesetting environments.}
% \end{enumerate}
%
% We will now explain all required macros.
%
% \subsubsection{Treat the implicit spelchunks}
% \<<<{
%   The texts of chapter, (sub)section titles, a.s.o. will be formatted
%   automatically such that they are hyperlinked to the appropriate
%   audio file. Therefore, this step was not mentioned above. It is done
%   automatically for you by using the \spelatex{} package.
% }
%
% \<<<{
%   You only need to cover your \emph{defunct implicit spelchunks}:\\
%   \DescribeMacro{\spelitem}
%   Use this macro instead of the \texttt{\textbackslash{}item} macro to make
%   sure your list environments are converted to speech chunks
%   appropriately.
% }
%
% \begin{spelchunk}
%   Example:
% \begin{Verbatim}
%   We like
%   \begin{itemize}
%     \spelitem{apples,}
%     \spelitem{pears, and}
%     \spelitem{oranges.}
%   \end{itemize}
% \end{Verbatim}
% \end{spelchunk}
% \begin{spelchunk}
%   Another example:
% \begin{Verbatim}
%   If you don't know these fruits:
%   \begin{description}
%     \spelitem[apple]{a green round fruit}
%     \spelitem[pears]{a green pointy-shaped fruit}
%     \spelitem[orange]{an orange round fruit}
%   \end{description}
% \end{Verbatim}
% \end{spelchunk}
%
% \subsubsection{Treat the explicit spelchunks}
% \label{sec:explicitspelchunks}
% \<<<{
%   \DescribeEnv{spelchunk}
%   Use this environment to embed the chunks of text in that you want
%   to generate audio for. In case the content is an equation, a
%   figure or a table, we recommend specifying |arealink| as the
%   optional argument to the |spelchunk| environment. It makes the
%   entire equation an active hyperlink.
%   Note that you cannot specify an |arealink| when the area to be covered is
%   vertical-mode object. In common language: put your |arealink| |spelchunk|
%   environments inside a |center| environment and not the other way around.
% }
%
% \<<<{
%   Example:\\
%   {\footnotesize (note: the example below is not \spelatex{}-enabled
%   in this manual because it generates internal package problems)}
% }
% \begin{Verbatim}
%   \begin{spelchunk}
%     An ordinary paragraph must be embedded in this environment.
%     The same holds for equations! However, then we recommend using
%     the |arealink| option, as that makes the full area of the
%     equation clickable and avoids an empty white line before the
%     equation.
%   \end{spelchunk}
%   \begin{spelchunk[arealink]
%     \begin{align}
%       E &= m c^2\\
%       e^{j\pi} &= -1
%     \end{align}
%   \end{spelchunk}
% \end{Verbatim}
%
%
% \subsubsection{Manually provide text to read when needed}
% \begin{spelchunk}
%   \DescribeEnv{spelchunkad}
%   If you want a different text to be used for the previous
%   spelchunk environment, this environment allows you to specify it.
%   For plain text or math environments, this is also your generic escape
%   route in case the \spelpl{} parser does not work as you'd like
%   it to.\\
% \end{spelchunk}
% \begin{spelchunk}
%   Just have your |spelchunk| environment followed by a
%   |spelchunkad| environment that specifies the correct text to read
%   out loud. However, please, file a bug report, such that we can
%   improve the tool.
% \end{spelchunk}
%
% \begin{spelchunk}
%   Example:\\
%   {\footnotesize (note: the example below is again not \spelatex{}-enabled because it
%   generates internal package problems)}
% \end{spelchunk}
% \begin{Verbatim}
%   \begin{spelchunk}
%     An ordinary paragraph must be embedded in this environment.
%   \end{spelchunk}
%   \begin{spelchunkad}
%     Do not forget to embed ordinary paragraphs in this environment.
%   \end{spelchunkad}
% \end{Verbatim}
%
% \begin{spelchunk}
%   For non-textual material such as figures or tables, this allows you
%   to specify a sensible text that acts as an audio description for
%   that material.\\
%   Just have your |spelchunk| environment that surrounds your figure
%   or table, followed by a |spelchunkad| environment that provides
%   the audio description for the non-textual material.
% \end{spelchunk}
% 
% \begin{spelchunk}
%   Example:\\
%   {\footnotesize (note: the example below is for a third time not \spelatex{}-enabled because it
%   generates internal package problems)}
% \end{spelchunk}
% \begin{Verbatim}
%   \begin{spelchunk}
%     \includegraphics{engine.jpg}  
%   \end{spelchunk}
%   \begin{spelchunkad}
%     The image shows a turbo-fan engine of an aircraft. One can
%     clearly see the silver blades of the fan, and the housing. Note
%     how little spacing there is between the blades and the housing.
%   \end{spelchunkad}
% \end{Verbatim}
%
% \subsubsection{Use the shorthand \texttt{\textbackslash <<<}-macro}
%
% \DescribeMacro{\<<<}
% \<<<{
%   This macro takes the text to be read-out loud as an
%   argument. It is a shorthand for the |spelchunk|
%   environment. Options you would have given to the |spelchunk|
%   environment can be given as an optional argument to this macro.
% }
% 
% \<<<{
%   Retaking the example of section~\ref{sec:explicitspelchunks},
%   using the shorthand, we obtain:\\ 
%   {\footnotesize (note: the example below is once again not \spelatex{}-enabled
%   in this manual because it generates internal package problems)}
% }
% \begin{Verbatim}
%   \<<<{
%     An ordinary paragraph must be embedded in this macro.
%     The same holds for equations! However, then we recommend using
%     the |arealink| option, as that makes the full area of the
%     equation clickable and avoids an empty white line before the
%     equation.
%   }
%   \<<<[arealink]{
%     \begin{align}
%       E &= m c^2\\
%       e^{j\pi} &= -1
%     \end{align}
%   }
% \end{Verbatim}
%
%
% \subsubsection{Provide descriptions for typesetting macros}
%
% \DescribeMacro{\spelmacad}
% \begin{spelchunk}
%   Often, recurring constructs are being typeset using a dedicated
%   macro, defined by the user.
%   For example, to consistently typeset input voltages for arbitrary pins,
%   one might have defined the macro:
% \begin{Verbatim}
%   \newcommand\vin[2][IN]{\ensuremath{v_{\mathit{#1},#2}}}
% \end{Verbatim}
% \end{spelchunk}
% \newcommand\vin[2][IN]{\ensuremath{v_{\mathit{#1},#2}}}%
% \spelmacad{vin}[2][IN]{the #1put voltage at pin #2}%
% \begin{spelchunk}
%   This allows easy specification of
% \begin{Verbatim}
%   \vin{1} = \sin 20 t
% \end{Verbatim}
% resulting in $\vin{1} = \sin 20 t$.
% \end{spelchunk}
%
% \begin{spelchunk}
%   However one might want this line to be read as 'the input voltage
%   at pin 1 equals sine 20 t'.\\
%   To this end, one can provide an description for this macro
%   using the |spelmacad| macro.
% \end{spelchunk}
%
% \begin{spelchunk}
%   Example:
% \begin{Verbatim}
%   \spelmacad{vin}[1][IN]{the #1put voltage at pin #2}
% \end{Verbatim}
%   Note that the audio description in this case will only be
%   acceptable, for arguments IN and OUT. One clearly has to take the
%   audio description into account when defining \LaTeX{}-macros.
% \end{spelchunk}
%
% \subsubsection{Descriptions for typesetting environments}
%
% \DescribeMacro{\spelenvad}
% \begin{spelchunk}
%   Often, recurring constructs are being typeset using a dedicated
%   environment, defined by the user.
%   For example, to consistently typeset a proof or illustration one might
%   have defined the environment: 
% \begin{Verbatim}
%   \newenvironment{proof}[2][Proof]{
%     \textbf{#1: #2}\\
%   }
%   {
%     \hfill$\blacksquare$\\
%   }
% \end{Verbatim}
% \end{spelchunk}
% \begin{spelchunk}
%   This allows easy specification of an illustration as:
% \begin{Verbatim}
%   \begin{proof}[Illustration]{solving a quadratic equation}
%     blabla
%   \end{proof}
% \end{Verbatim}
% \end{spelchunk}
% \begin{spelchunk}
%   However one might want this environment to be read as
%   'Illustration of solving a quadratic equation: blabla. This
%   concludes this illustration.'\\
%   To this end, one can provide an description for this macro
%   using the |spelenvad| macro.
% \end{spelchunk}
%
%
% \begin{spelchunk}
%   Example:
% \begin{Verbatim}
%   \spelenvad{proof}[1][Illustration]
%   {#1 of #2:}
%   {This concludes this #1.}
% \end{Verbatim}
% \end{spelchunk}
%
% \subsubsection{Inline descriptions}
% \DescribeMacro{\spelinlad}
% \<<<{
%   Sometimes a spel chunk contains a subblock that cannot be treated by the
%   wizard. E.g., een tikzpicture that is included in an align environment.
%   Nesting spelchunks is unfortunately not possible.
%   In that case, one can use the |\spelinlad| macro. This takes two arguments,
%   the first being the part that needs to end up in your written manuscript,
%   the second argument is the audio description.}
%
% \<<<{The following equation illustrates its use:}
% \begin{Verbatim}
%   \begin{spelchunk}[arealink]
%     \begin{align}
%       \phi &= \arctan \frac{\sqrt{1-\zeta^2}}{\zeta}\\
%        &~~\spelinlad{
%             \begin{tikzpicture}
%               \draw[->] (-0.5,1) -- (-0.5,-0.5);
%               \draw(0,0) -- node[below] {$\zeta$} (2,0)
%                 -- node[right] {$\sqrt{1-\zeta^2}$} (2,1)
%                 -- node[above left] {$1$} cycle;
%               \draw (0:0.5) arc (0:28:0.5);
%             \end{tikzpicture}
%           }{\text{Given the trigonometric relations in the triangle,
%                   we can deduce}}\\
%            &= \arccos \zeta
%     \end{align}
%   \end{spelchunk}
% \end{Verbatim}
%
% \<<<{When you run this code through \LaTeX{} you obtain:}
% \begin{spelchunk}[arealink]
%   \begin{align}
%     \phi &= \arctan \frac{\sqrt{1-\zeta^2}}{\zeta}\\
%      &~~\spelinlad{
%           \begin{tikzpicture}
%             \draw[->] (-0.5,1) -- (-0.5,-0.5);
%             \draw(0,0) -- node[below] {$\zeta$} (2,0)
%               -- node[right] {$\sqrt{1-\zeta^2}$} (2,1)
%               -- node[above left] {$1$} cycle;
%             \draw (0:0.5) arc (0:28:0.5);
%           \end{tikzpicture}
%         }{\text{Given the trigonometric relations in the triangle,
%                 we can deduce}}\\
%          &= \arccos \zeta
%   \end{align}
% \end{spelchunk}
%
% \subsubsection{Using the i18n features of \spelpl when describing
% your macros and environments}
% \begin{spelchunk}
%   Sooner rather than later you will feel the need to provide reading
%   alternatives for your constructs that are language dependent. In
%   that case you can call the i18n features that are built into
%   \spelpl. We illustrate this with an example.
% \end{spelchunk}
%
% \begin{spelchunk}
%   Assume you've made your own command to raise numbers to a power,
%   and you provide and description for your macro.
% \end{spelchunk}
% \begin{Verbatim}
%   \newcommand\numtopower[2]{#1^{#2}}
%   \spelmacad{numtopower}[2]{#1 to the power of #2}
% \end{Verbatim}
% 
% \begin{spelchunk}
%   The problem with this solution is, that it only works for one
%   language. The solution is to use an i18n expression in your
%   description: 
% \end{spelchunk}
% \begin{Verbatim}
%   \spelmacad{numtopower}[2]{#1 @{i18n(Power,#2)}}
% \end{Verbatim}
% \begin{spelchunk}
%    This will call the maketext function (See Locale::Maketext) on
%    the Lexicon provided in SpeL::Wizard::I18n, as:
% \end{spelchunk}
% \begin{Verbatim}
%   $SpeL::Wizzard::I18n::lh->maketext( 'Power', "#2")
% \end{Verbatim}
% \begin{spelchunk}
%   to read your macro.
% \end{spelchunk}
%
% \subsubsection{The extra math commands}
% Note that these commands are only available if you provide the
% package option |extramath|.
%
% \DescribeMacro{\setenum}
% \begin{spelchunk}
%   This macro typesets an enumeration set and makes sure \spelpl{}
%   can read it properly.
% \end{spelchunk}
% \begin{spelchunk}
% \begin{Verbatim}
%   \begin{equation}
%     P = \setenum{ 2, 3, 5, 7, 11, 13, \ldots }
%   \end{equation}
% \end{Verbatim}
% \end{spelchunk}
%
% \DescribeMacro{\setdesc}
% \begin{spelchunk}
%   This macro typesets a definition set and makes sure \spelpl{}
%   can read it properly.
% \end{spelchunk}
% \begin{spelchunk}
% \begin{Verbatim}
%   \begin{equation}
%     P = \setdesc{ n \in \mathbb{N} \mid n \text{~is prime} }
%   \end{equation}
% \end{Verbatim}
% \end{spelchunk}
%
% \subsection{Going through the flow}
% \begin{spelchunk}
%   Once your document source has been prepared, you are ready for the
%   regular \spelatex-flow. It consists of 3 steps.
% \end{spelchunk}
%
% \begin{enumerate}
%   \spelitem{Create a \texttt{jobname-spel} subdirectory in the
%   working directory your \LaTeX{} source document is in (replace
%   jobname with the basename of your latex file, the final
%   \texttt{-spel} is a literal).}
%   \spelitem{Run your document
%   3-times through your \{pdf,Xe,Lua\}\LaTeX{}-compiler to get all
%   the references right.}
%   \spelitem{Run the \spelpl{} speech
%   generator (see scripts directory or the wrapper provided by the
%   package manager), by launching it with the base name of your
%   document as command-line
%   argument.\\
%   E.g.: \texttt{\spelpl{} -v example}}\\
%   The |-v| argument causes the script to be somewhat more verbose.
% \end{enumerate}
% 
% \begin{spelchunk}
%   The result of this will be a PDF file equipped with links to audio
%   files in the 'speech' subdirectory. Alas your PDF file has been
%   become a little less portable, as it now requires the 'speech'
%   subdirectory to be complete. You might want to package the
%   ensemble into a tar-file or zip-archive.
% \end{spelchunk}
%
%%
% \section{Example}
%
% \begin{spelchunk}
%   Below, you can find a simple example to give you a head-start.
%   In order not to spoil the fun for you, the embedded version here
%   is not speech-enabled.
% \end{spelchunk}
%
% \begin{VerbatimOut}[gobble=4]{Example/example.tex}
%   \documentclass{report}
%   
%   \usepackage[dutch,english]{babel}   % load babel before spelatex to avoid
%                                       % option clash!
%   \selectlanguage{english}
%   \usepackage[format=ogg,
%               server=https://ctan.org/tex-archive/macros/latex/contrib/spelatex/Example
%              ]
%              {spelatex}
%
%   \newrobustcmd\CTAN{CTAN}
%   \spelmacad{CTAN}{see-tan}
%   \newrobustcmd\CPAN{CPAN}
%   \spelmacad{CPAN}{see-pan}
%
%   \title{\spelatex{} Example}
%   \author{Walter Daems and Paul Levrie}
%   \date{2025/06/15}
%   \setlength\parindent{0em}
%   \setlength\parskip{1ex}
%
%   \begin{document}
%   
%   \maketitle
%   
%   \chapter{Introduction}
%
%   \<<<{
%     This file is just a simple showcase of the features of \spelatex{}.
%     Below, you'll find examples of:
%   }
%
%   \begin{itemize}
%     \spelitem{a simple equation}
%     \spelitem{a more complex equation}
%   \end{itemize}
%
%   \chapter{Examples}
%   \section{A simple equation}
%   \label{eqn:simple}
%   \<<<{
%     Consider the following simple definition of a polynomial function and
%     check its spoken version by clicking on it.
%   }
%   \<<<[arealink]{
%     \begin{equation}
%       f(x) = x^{5}- x^4 + 7 x^3 + 3 x^2 - 8 x + 25
%     \end{equation}
%   }
%   \<<<{
%     This seems a simple equation, however, it is not so straightforward
%     for an automated reader, to read it correctly.
%   }
%
%   \section{A more complex equation}
%   \newcommand\xx[2]{\ensuremath{#1_{#2}}}
%   \spelmacad{xx}[2]{#1 #2}
%
%   \label{eqn:complex}
%   \begin{spelchunk}
%     For a lightray that hits the parabola at the point
%     $P(t,9-\frac{t^2}{4})$, the reflected ray has slope $\tan 2\alpha$.
%     Since the slope of the tangent to the parabola at $P$ is
%     equal to $\tan\alpha = -\frac{t}{2}$, the equation of the
%     reflected ray is given by
%   \end{spelchunk}
%   \begin{spelchunk}[arealink]
%     \[
%     y-9+\frac{t^2}{4} = -\frac{4t}{4-t^2} \cdot (x-t)
%     \]
%   \end{spelchunk}

%   \section{Remark}
%   \<<<{
%   Instead of the \texttt{\textbackslash{}<<<} macro, one can also use the
%   spelchunk environment. We did this in the next sections.
%   }
%
%   \chapter{More advanced topics}
%
%   \selectlanguage{dutch}
%   \section{Een andere taal}
%   \begin{spelchunk}
%   \spelatex{} is ook volledig babel-actief, wat wil zeggen dat de
%   voorleesstem de geselecteerde taal zal volgen.
%   \end{spelchunk}
%
%   \begin{spelchunk}[arealink]
%     \[
%     y-9+\frac{t^2}{4} = -\frac{4t}{4-t^2} \cdot (x-t)
%     \]
%   \end{spelchunk}
%
%   \selectlanguage{english}
%
%   \section{And some extras}
%   \subsection{Citations}
%   \begin{spelchunk}
%   Two excellent repositories are \CPAN{} \cite{CPAN} and \CTAN{} \cite{CTAN}.
%   \end{spelchunk}
% 
%   \subsection{References to labels}
%   \begin{spelchunk}
%   Section~\ref{eqn:simple} contains an illustration of a simple
%   equation. For a more complex equation, we refer the user to
%   section~\ref{eqn:complex}.
%   \end{spelchunk}
%
%   \selectlanguage{dutch}
%
%   \bibliographystyle{alpha}
%
%   \begin{thebibliography}{99}
%
%   \bibitem{CTAN}
%   The Comprehensive \TeX{} Archive Network.
%   \newblock \url{http://www.ctan.org}.
%   \newblock online, accessed in August 2021.
%
%   \bibitem{CPAN} 
%   The Comprehensive Perl Archive Network.
%   \newblock \url{http://www.cpan.org}.
%   \newblock online, accessed in August 2021.
%
%   \end{thebibliography}
%
%   \end{document}
% \end{VerbatimOut}
% \footnotesize
% \VerbatimInput[frame=lines,numbers=left,gobble=0]{Example/example.tex}
% \normalsize
% \section{Demo}
% \label{sec:demo}
% \newcommand\rd[1]{\ensuremath{\mathrm{d}#1}}
% \spelmacad{rd}[1]{d of #1}
% \newcommand\xx[2]{\ensuremath{#1_{#2}}}
%
% \begin{spelchunk}
%   The examples below have been composed and used to test the math
%   reading capabilities of \spelatex{} and \spelpl. The source code has not
%   been made visible in this document. If you'd like to see the
%   source code, check the original |.dtx|-file that was used to
%   generate this PDF-file.
% \end{spelchunk}
% 
% \subsection{Numbers}
% \begin{spelchunk}[arealink]
%   \begin{align}
%     \pi\\
%     -31415\\
%     1.25\\
%     -0.34 \times 10^{4}\\
%     12 - j 3\\
%     -31415.23 + .45i
%   \end{align}
% \end{spelchunk}
% 
%
% \subsection{Fractions}
% \subsubsection{A fraction only containing numbers}
% \<<<{You will probably have seen more complex numbers in your life.}
%   \begin{spelalign}
%     x &= - \frac{1}{2} \\
%     y &= - \sqrt{\frac{\pi}{2}}
%   \end{spelalign}
% \begin{spelchunk}
%   Or should I say real numbers?
% \end{spelchunk}
%
% \subsubsection{A fraction with a little more under the hood}
% \begin{spelchunk}[arealink]
%   \begin{align}
%     u &= - \frac{x^2+35}{\sqrt{12}} \\
%     v &= - \frac{\sqrt{\frac{\pi}{2}}}{-3x^2+3}
%   \end{align}
% \end{spelchunk}
%
%
% \subsection{Simple expressions}
% \subsubsection{A polynomial function}%
% \begin{spelchunk}[arealink]
%   \begin{equation}
%     f(x) = x^{5}- x^4 + 7 x^3 + 3 x^2 - 8 x + 23
%   \end{equation}
% \end{spelchunk}
%
% \subsubsection{Some more complex equations}
% \begin{spelchunk}
%   Here's de Moivre's formula:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \begin{equation}
%     \left(\cos x+j\sin x\right)^n=\cos(nx)+j\sin(nx)
%   \end{equation}
% \end{spelchunk}
%
% \begin{spelchunk}
% Euler's relationship:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \begin{equation}
%     e^{j \phi} = \cos \phi + j \sin \phi
%   \end{equation}
% \end{spelchunk}
%
% \begin{spelchunk}
% Euler's identity:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \begin{equation}
%     e^{j \pi} + 1 = 0
%   \end{equation}
% \end{spelchunk}
%
% \subsubsection{A rather well-known definite integral}
% \begin{spelchunk}[arealink]
%   \begin{equation}
%     \int_{-\infty}^\infty e^{-x^2}\,\rd{x} = \sqrt{\pi}
%   \end{equation}
% \end{spelchunk}
%
% \subsection{Sets}
% \begin{spelchunk}
%   Let's check the two set commands this package provides:
%   \texttt{\textbackslash{}setenum} and
%   \texttt{\textbackslash{}setdesc}: 
% \end{spelchunk}
% \begin{spelchunk}[arealink]
% \begin{align}
%     P &= \setenum{ 2, 3, 5, 7, 11, 13, \ldots }\\
%     P &= \setdesc{ n \in \mathbb{N} \mid n \text{~is prime}}
% \end{align}
% \end{spelchunk}
%
% \subsection{Matrices}
% \begin{spelchunk}
%   How about some linear algebra?
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \begin{align}
%     \begin{bmatrix}
%        3 & 4 \\
%        7 & 2
%     \end{bmatrix}
%     \cdot
%     \begin{bmatrix}
%        x \\ y
%     \end{bmatrix}
%     &= 
%     \begin{bmatrix}
%        1 \\ 0
%     \end{bmatrix}\\
%     \begin{vmatrix}
%        3 & 4 \\
%        7 & 2
%     \end{vmatrix}
%     &= -22
%   \end{align}
% \end{spelchunk}
% 
% \subsection{Figures and Tables}
% \subsubsection{Figures}
% \begin{spelchunk}
%   The example Fig.~\ref{fig:blockdiagram} illustrates the voice-aid
%   that can be added to figures.
% \end{spelchunk}
% \begin{figure}[h]
% \setlength{\unitlength}{4mm}
% \begin{center}
%   \begin{spelchunk}[arealink]
%   \begin{picture}(24,2)
%     \put(0,0.8){$x[n]$}
%     \put(2,1){\vector(1,0){3}}
%     \put(5,0){\framebox(5,2){$H(z)$}}
%     \put(10,1){\vector(1,0){3}}
%     \put(13,0){\framebox(5,2){$G(z) \cdot F(z)$}}
%     \put(18,1){\vector(1,0){3}}
%     \put(22,0.8){$y[n]$}
%   \end{picture}
%   \end{spelchunk}
% \end{center}
% \begin{spelchunkad}
%   The discrete-time input signal x is fed through a filter H of
%   z. The intermediate output signal of the filter H of z is fed into
%   another filter whose transfer function is the product of G of
%   z and F of z. This results in the discrete-time output signal y.
% \end{spelchunkad}
% \spelcaption{A block diagram of the filter system}
% \label{fig:blockdiagram}
% \end{figure}
%
% \subsubsection{Tables}
% \<<<{Tables can also be equiped with a sensible description:}
% \begin{center}
%   \begin{spelchunk}[arealink]
%     \begin{tabular}{lcc}
%       Food                   & Sweet     & Bitter \\
%       \hline
%       apples                 & $\bullet$ & \\ 
%       unsweetened coffee     &           & $\bullet$\\
%       cake                   & $\bullet$ & \\
%       chocolate              & $\bullet$ & $\bullet$ \\
%       \hline
%     \end{tabular}
%   \end{spelchunk}
% \end{center}
% \begin{spelchunkad}
%   This table indicates the sweetness and bitterness for several food
%   products.
%   It lists apples that are (sweet); unsweetened coffee which is
%   bitter; cake which is sweet and chocolate that is both sweet and bitter.
% \end{spelchunkad}
% \subsection{A parabola tale}
%
% \begin{spelchunk}
%   For a lightray that hits the parabola at the point
%   $P(t,9-\frac{t^2}{4})$, the reflected ray has slope $\tan 2\alpha$.
%   Since the slope of the tangent to the parabola at $P$ is equal
%   to $\tan \alpha = -\frac{t}{2}$, the equation of the reflected
%   ray is given by
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \begin{equation}
%   y-9+\frac{t^2}{4} = -\frac{4t}{4-t^2} \cdot (x-t)
%   \end{equation}
% \end{spelchunk}
% \begin{spelchunk}
%   The $x$-coordinate of the point of intersection of the reflected ray
%   with a fixed line $y=u$ satisfies:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \begin{equation}
%   u-9+\frac{t^2}{4} = -\frac{4t}{4-t^2} \cdot (x-t)
%   \label{eqn:refray}
%   \end{equation}
% \end{spelchunk}
% \begin{spelchunk}
%   We calculate the minimal value of this $x$ for varying $t$, by
%   differentiating (\ref{eqn:refray}) with respect to $t$ and assuming
%   that $\frac{\rd{x}}{\rd{t}}=0$:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \[
%   \frac{t}{2} = -\frac{4(4+t^2)}{(4-t^2)^2} (x-t) -
%   \frac{4t}{4-t^2} \cdot (-1) \ \ \ \Leftrightarrow \ \ \ x=
%   3\frac{t}{2}-\frac{t^3}{8}
%   \]
% \end{spelchunk}
% \begin{spelchunk}
% Inserting in the equation containing $u$ gives us the relation
% between $t$ and $u$:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \[
%   u = 9- 3 \frac{t^2}{4}
%   \]
% \end{spelchunk}
%% \begin{spelchunk}
%   This leads to a system of parametric equations for the caustic:
% \end{spelchunk}
% \begin{spelchunk}[arealink]
%   \[
%   \left\{\begin{array}{l}
%       x = 3\frac{t}{2}-\frac{t^3}{8} \\[0.3cm]
%       y = 9- 3 \frac{t^2}{4}
%     \end{array} \right.
%   \quad \Leftrightarrow \quad
%   \left\{\begin{array}{l}
%       x = \frac{t}{2} \cdot (3 -\frac{t^2}{4}) \\
%       y = 3(3- \frac{t^2}{4})
%     \end{array} \right.
%   \]
% \end{spelchunk}
% \begin{spelchunk}
%   It is now easy to eliminate the parameter $t$. As you can see, $t
%   = \frac{6 x}{y}$. Inserting into the equation for $y$ gives us the
%   equation of Tschirnhausen's cubic.
% \end{spelchunk}
%
%
% \section{Implementation}
% \begin{spelchunk}
%   To ease the implementation work and because raw \LaTeX{} code is
%   difficult to read on itself, We took the liberty of not providing
%   this section with speech chunks (except for this introduction
%   text).
% \end{spelchunk}
%
%
% \iffalse
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% \fi
%
% \subsection{Design principles}
%
% \spelatex{} has been developed using the following main targets in
% mind. Some of them are common sense design principles, some of them
% are specific for this application.
% \begin{itemize}
%   \item minimal effort in preparing a \LaTeX{} manuscript for use with
%     \spelatex{}
%   \item maximal compatibility with existing \LaTeX{} packages
%   \item no (or minimal) compromise mathematical reading capabilities
%     for mathematical constructs
%   \item user extensible audio preprocessor
%   \item minimal use of processing power for text to speech conversion
% \end{itemize}
% 
% 
% \subsection{Auxiliary Packages}
% The \spelatex{} package uses some basic auxiliary packages to make life
% easy.
%    \begin{macrocode}
\RequirePackage{expl3}
\RequirePackage{hyperref}
\RequirePackage{xcolor}
\RequirePackage{ifthen}
\RequirePackage{verbatim}
\RequirePackage{fancyvrb}
\RequirePackage{newfile}
\RequirePackage{rotating}
\RequirePackage{babel}
\RequirePackage{kvoptions}
\RequirePackage{xkeyval}
%    \end{macrocode}
%
% \subsection{Options}
%
%    \begin{macrocode}
\SetupKeyvalOptions{
  family=spel,
  prefix=spel@
}
\DeclareStringOption[ogg]{format}
\DeclareStringOption[local]{server}
\DeclareStringOption[full]{markervisibility}
\DeclareBoolOption[false]{disabled}
\DeclareBoolOption[false]{extramath}
\DeclareStringOption[{}]{elements}
\ProcessKeyvalOptions*
%    \end{macrocode}
%
% \subsection{Logos}
% Vanity is everything, so let's make some logoware.
% \begin{macro}{\spelatex}
%   This is the official \spelatex{} logo.
%    \begin{macrocode}
\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}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\spelpl}
%   This is the official \spelpl{} logo.
%    \begin{macrocode}
\DeclareRobustCommand{\spelpl}{\texttt{spel-wizard.pl}}
%    \end{macrocode}
% \end{macro}
% 
% \subsection{The speech stream}
% The basic structural elements of a document (title, chapters,
% sections, \ldots) are written to the speech index stream. This is a
% textfile that has the same base name as your \LaTeX{} job and has
% extension |.spelidx|. 
% 
% It is the index to the chunks of text that are written to the speech
% directory.
%
% The |.spelidx| file requires postprocessing by the \spelpl{}
% script in order to obtain the required audio files.
% 
% The speech stream needs to be open before the preamble's title,
% author and date.
%    \begin{macrocode}
\newoutputstream{chunk}
\newoutputstream{spelidx}
\openoutputfile{\jobname.spelidx}{spelidx}
%    \end{macrocode}
% The stream needs to be closed upon termination of the document.
%    \begin{macrocode}
\AtEndDocument{
  \closeoutputstream{spelidx}%
}
%    \end{macrocode}
%
% To begin with, we write the standard locations for audio and chunk
% data to the |.spelidx| file.
%    \begin{macrocode}
\newcommand\audiodir{\jobname-spel}
\newcommand\chunkdir{\jobname-spel}
\addtostream{spelidx}{format|\spel@format}
\addtostream{spelidx}{audiodir|\audiodir}
\addtostream{spelidx}{chunkdir|\chunkdir}
\addtostream{spelidx}{server|\spel@server}
\ExplSyntaxOn
\newcommand\linksdir{
  \str_if_eq:VnTF{\spel@server}{local}{./\audiodir}{\spel@server/\audiodir}
}
\ExplSyntaxOff
%    \end{macrocode}
% 
% To ease writing to the speech index stream, we define a |\spelidxwrite|
% function to take care of appropriate formatting.
% \begin{macro}{\spel@idxwrite}
%   This is an internal macro, used to write information to the |.spelidx|
%   file and to a correspondig chunk file.
%    \begin{macrocode}
\ifspel@disabled\newcommand{\spel@idxwrite}[2]{}\else
\newcommand{\spel@idxwrite}[2]{%
  \typeout{SpeLaTeX: Generating #1 - #2}%
  \addtostream{spelidx}{#1|#2}%
}
\fi
%    \end{macrocode}
% \end{macro}
%
% To ease writing speech chunk, we define a |\spel@chunkwrite|
% function.
% \begin{macro}{\spel@chunkwrite}
%   This is an internal macro, used to write information to the speech chunk
%   files.
%    \begin{macrocode}
\ifspel@disabled\newcommand{\spel@chunkwrite}[2]{}\else
\newcommand{\spel@chunkwrite}[2]{%
  \openoutputfile{\audiodir/#1.tex}{chunk}%
  \addtostream{chunk}{#2}%
  \closeoutputstream{chunk}%
}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsection{Create missing counters}
% As we need to be able to fully identify every speech chunk, we need
% to provide some missing counters for the starred versions of the
% sectioning commands.
%
% \begin{macro}{spel@spart} counter
%    \begin{macrocode}
\newcounter{spel@spart}
\renewcommand\thespel@spart{\@arabic\c@spel@spart}
\setcounter{spel@spart}{0}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{spel@schapter} counter
%    \begin{macrocode}
\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
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{spel@ssect} counter
%    \begin{macrocode} 
\ifx\c@chapter\@undefined
\newcounter{spel@ssect}
\else
\newcounter{spel@ssect}[chapter]
\fi
\renewcommand\thespel@ssect{\@arabic\c@spel@ssect}
\setcounter{spel@ssect}{0}
%    \end{macrocode}
% \end{macro}
%
% In addition, some elements that are not canonically numbered require
% a unique and monotonous numbering.
% \begin{macro}{spel@footnote} counter
%    \begin{macrocode}
\newcounter{spel@footnote}
\renewcommand\thespel@footnote{\@arabic\c@spel@footnote}
\setcounter{spel@footnote}{0}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{spel@chunk} counter
%    \begin{macrocode}
\newcounter{spel@chunk}[subparagraph]
\renewcommand\thespel@chunk{\@arabic\c@spel@chunk}
\setcounter{spel@chunk}{0}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Setting up the language}
% We want to make sure that babel communicates the switching of
% langauges to spel, such that it can take not of it. This allows the
% spel engine to select an appropriate language-capable voice when
% generating the spoken text.
%    \begin{macrocode}
\AddBabelHook{informspel}{write}{\spel@idxwrite{language}{\languagename}}
\EnableBabelHook{informspel}
%    \end{macrocode}
%
% \subsection{Setting up the visibility}
%
%    \begin{macrocode}
\ExplSyntaxOn
\definecolor{faintgray}{rgb}{0.9,0.9,0.9}
\str_if_eq:VnTF{\spel@markervisibility}{none}{
  \colorlet{spel@color@right}{white}
  \colorlet{spel@color@left}{white}
}{}
\str_if_eq:VnTF{\spel@markervisibility}{onlygroups}{
  \colorlet{spel@color@right}{black!25}
  \colorlet{spel@color@left}{white}
}{}
\str_if_eq:VnTF{\spel@markervisibility}{full}{
  \colorlet{spel@color@right}{black!25}
  \colorlet{spel@color@left}{black!25}
}{}
\ExplSyntaxOff
%    \end{macrocode}
%
%
%
% \subsection{Generating speech chunks --- implicitly}
% \subsubsection{Auxiliary macros}
% We define a macro to generate wrappers for single-line text elements.
% The |\spel@registerelement| macro does
% the job. The user can even use the macro for his own custom
% single-line text elements (e.g., for a subtitle, a version string).
% \begin{macro}{\spel@registerelement}
% generic macro to register single-line text elements
%    \begin{macrocode}
\ifspel@disabled
  \newcommand{\spel@registerelement}[1]{}
  \def\processelementlist#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{\linksdir/#1.\spel@format}{##1}}
    \spel@idxwrite{#1}{#1}
  }
}
\def\processelementlist#1{%
  \def\do##1{\spel@registerelement{##1}}%
  \edef\@tempa{#1}%
  \expandafter\docsvlist\expandafter{\@tempa}%
}
\def\docsvlist#1{%CSV-list-processor
  \@for\@tempa:=#1\do{\expandafter\do\expandafter{\@tempa}}%
}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Title elements}
% By redefining the title elements, |\title|, |\author| and |\date| we
% avoid having to chunk them.
%
% Using this macro, we can easily take care of all title-like
% elements,  including the ones specified through the elements option:
%    \begin{macrocode}
\spel@idxwrite{language}{\languagename}
\spel@registerelement{title}
\spel@registerelement{date}
\spel@registerelement{author}
\processelementlist{\spel@elements}
\let\spel@@maketitle\maketitle
\gdef\maketitle{{\hypersetup{hidelinks}\spel@@maketitle}}
%    \end{macrocode}
% We registered the initial language in advance, to make sure the
% wizard knows what language to use for these elements.
%
% \subsubsection{Table of contents}
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% \subsubsection{Sectioning commands}
%
% \begin{macro}{\@part}
%   This is a simple wrapper around the regular |\@part| macro.
%    \begin{macrocode}
\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{\linksdir/\spel@@optpart.\spel@format}{#2}}%
  \spel@idxwrite{part \thepart}{\spel@@optpart}%
  \spel@chunkwrite{\spel@@optpart}{#2}%
}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@spart}
%   This is a simple wrapper around the regular |\@spart| macro.
%    \begin{macrocode}
\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{\linksdir/\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
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@chapter}
%   This is a simple wrapper around the regular |\@chapter| macro.
%   It is defined conditionally on the existence of the |\chapter| macro.
%    \begin{macrocode}
\newcommand\hideref[2]{\protect\hypersetup{hidelinks}\href{#1}{#2}}
\newif\ifspel@inschapter
\spel@inschapterfalse
\ifspel@disabled\else
\ifx\thechapter\@undefined\else%
\renewcommand\thechapter{%
\ifspel@inschapter star-\thespel@schapter\else\@arabic\c@chapter\fi%
}
\fi
\ifx\chapter\@undefined\else
\let\spel@@chapter\@chapter
\def\@chapter[#1]#2{%
  \spel@inschapterfalse%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@chapter[#1]{%
    \hideref{\linksdir/\spel@@optpart\thechapter.\spel@format}{#2}}%
  \spel@idxwrite{chapter \thechapter}{\spel@@optpart\thechapter}%
  \spel@chunkwrite{\spel@@optpart\thechapter}{#2}%
}
\fi
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@schapter}
%   This is a simple wrapper around the regular |\@schapter| macro.
%   It is defined condionally on the existence of the |\schapter| macro.
%    \begin{macrocode}
\ifspel@disabled\else
\ifx\chapter\@undefined\else
\let\spel@@schapter\@schapter
\def\@schapter#1{%
  \spel@inschaptertrue%
  \stepcounter{spel@schapter}%
  \setcounter{spel@chunk}{0}% need this because counter resetting fails
  \spel@@schapter{%
    \hideref{\linksdir/\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
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sect}
%   This is a simple wrapper around the regular |\@sect| macro.
%    \begin{macrocode}
\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]{%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph.\spel@format}{#8}\hfill%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph.m3u}
    {\textcolor{spel@color@right}{$\triangleright$}}}%
  \def\spel@@label{%
    \ifnum #2>\c@secnumdepth paragraph\else#1 \csname the#1\endcsname\fi}
  \spel@idxwrite{\spel@@label}{\spel@@optpart\thesubparagraph}%
  \spel@chunkwrite{\spel@@optpart\thesubparagraph}{#8}%
}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sect}
%   This is a simple wrapper around the regular |\@ssect| macro.
%    \begin{macrocode}
\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}{%
    \hideref{\linksdir/\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
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Notes}
%
% \begin{macro}{\@footnotetext}
%   This is a simple wrapper around the regular |\$footnotetext|
%   macro. We use a |spelfootnote| counter to keep track of the
%   individual footnotes.
%    \begin{macrocode}
\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}%
    \hideref{\linksdir/footnote-\thespel@footnote.\spel@format}
         {\usebox\spel@mptbox}#1}%
  \spel@idxwrite{footnote}{footnote-\thespel@footnote}%
  \spel@chunkwrite{footnote-\thespel@footnote}{#1}%
}
\fi
%    \end{macrocode}
% \end{macro}
% 
% \subsubsection{Itemizations/Enumerations}

% \begin{macro}{\spelitem}
%   This macro is to be used inside an enumerate, itemize, description
%   environment to automatically cause the generation of a speech
%   chunk.
%    \begin{macrocode}
\ifspel@disabled\newcommand{\spelitem}{\item}\else
\newcommand{\spelitem}{%
  \@ifnextchar[{\spelitem@opt}{\spelitem@intone}
}
\fi
%    \end{macrocode}
% \end{macro}
%
% This macro uses a number of auxiliary macros.
% \begin{macro}{\spelitem@opt}
%   This is an internal macro intended to deal with the |\item|'s
%   options.
%    \begin{macrocode}
\def\spelitem@opt[#1]{\spelitem@inttwo{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spelitem@opt}
%   This is an internal macro intended to deal with an |\spelitem| without
%   options.
%    \begin{macrocode}
\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}%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
    {\usebox\spel@mptbox}#1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spelitem@inttwo}
%   This is an internal macro intended to deal with an |\spelitem| with
%   options.
%    \begin{macrocode}
\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}%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
    {\usebox\spel@mptbox}#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spelitemcont}
%   This is a macro to continue an item after it has been interleaved
%   with a display item (e.g. a display math environment or another
%   itemization). 
%    \begin{macrocode}
\def\spelitemcont#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}%
  \hspace*{-\spel@mptboxwidth}{\hypersetup{hidelinks}%
    \href{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
    {\usebox\spel@mptbox}#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spelcaption}
%   This is a wrapper for the |\caption| macro, such that it is
%   \spelatex{} enabled.
%    \begin{macrocode}
\ifspel@disabled
  \newcommand\spelcaption[2][]{\caption[#1]{#2}}
\else
  \newcommand\spelcaption[2][]{%
    \stepcounter{spel@chunk}%
    \spel@idxwrite{caption}{\spel@@optpart\thesubparagraph-\thespel@chunk}%
    \spel@chunkwrite{\spel@@optpart\thesubparagraph-\thespel@chunk}{#2}%
    \caption[#1]{%
\protect\href{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
             {#2}}
  }
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Math environments}
%
% \begin{environment}{spelwrapenvironment}
%   This are all variants of a wrapper around a math environment
%   such that it is \spelatex{} enabled with an arealink.
%    \begin{macrocode}
\newcommand\spelwrapenvironment@b[1]{
  \NewDocumentEnvironment{spel#1}{+b}{
    \<<<[arealink]{%
      \begin{#1}
        ##1
      \end{#1}%
    }\hspace*{-0.75ex}%
  }{}%
}
\newcommand\spelwrapenvironment@ob[1]{
  \NewDocumentEnvironment{spel#1}{O{}+b}{
    \<<<[arealink]{
      \begin{#1}[##1]
        ##2
      \end{#1}
    }\hspace*{-0.75ex}%
  }{}
}
\newcommand\spelwrapenvironment@mb[1]{
  \NewDocumentEnvironment{spel#1}{m+b}{
    \<<<[arealink]{
      \begin{#1}{##1}
        ##2
      \end{#1}
    }\hspace*{-0.75ex}%
  }{}
}
\newcommand\spelwrapenvironment@mob[1]{
  \NewDocumentEnvironment{spel#1}{mO{}+b}{
    \<<<[arealink]{
      \begin{#1}{##1}[##2]
        ##3
      \end{#1}
    }\hspace*{-0.75ex}%
  }{}
}
\newcommand\spelwrapenvironment@omb[1]{
  \NewDocumentEnvironment{spel#1}{O{}m+b}{
    \<<<[arealink]{
      \begin{#1}[##1]{##2}
        ##3
      \end{#1}
    }\hspace*{-0.75ex}%
  }{}
}
%    \end{macrocode}
% \end{environment}
% Depending on the loading of amsmath, empheq and its overload option,
% we perform appropriate wrappings:
%    \begin{macrocode}
\AtBeginDocument{
  \@ifpackageloaded{amsmath}{
    \message{SpeLaTeX: detected amsmath package}
    \spelmacpp{ensuremath}[1]{#1}
    \@ifpackageloaded{empheq}{
      \message{SpeLaTeX: detected package empheq}
      \spelwrapenvironment@omb{empheq}}{}
    \@ifpackagewith{empheq}{overload}{
      \message{..........with overload option}
      \spelwrapenvironment@ob{gather}
      \spelwrapenvironment@ob{align}
      \spelwrapenvironment@mob{alignat}
    }
    {
      \message{..........without overload option}
      \spelwrapenvironment@b{gather}
      \spelwrapenvironment@b{align}
      \spelwrapenvironment@mb{alignat}
    }
  }
  {}
}
%    \end{macrocode}
%
% \subsection{Generating speech chunks --- explicitly}
%
% \subsubsection{Spel chunks to be parsed by \spelpl}
% \begin{environment}{spelchunk}
% The |spelchunk| environment is used to define explicit speech chunks.
%    \begin{macrocode}
\newlength\spel@mptboxwidth
\newsavebox\spel@mptbox
\savebox\spel@mptbox{%
  \textcolor{spel@color@left}
            {\quad\strut\tiny\raisebox{0.4ex}{$\triangleright$}\,}%
}
\newif\ifspel@chunkarealink
\define@key{spelchunk}{arealink}[]{\spel@chunkarealinktrue}
\ifspel@disabled
  \def\spelchunk{\@ifnextchar[{\spelchunk@optdisabled}{}}%
\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%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
         {\input{./\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk}}%
  \else%
  \settowidth\spel@mptboxwidth{\usebox\spel@mptbox}%
  \hspace*{-\spel@mptboxwidth}%
  \hideref{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
       {\usebox\spel@mptbox}%
       \input{./\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \fi%
  \spel@chunkarealinkfalse%
}%
\fi
%    \end{macrocode}
% \end{environment}
%
% The environment above checks if it is called with optional arguments
% or not.
% \begin{macro}{\spelchunk@opt}
%   This is macro that deals with the oatptional arguments of the
%   |spelchunk| envronment.
%    \begin{macrocode}
\def\spelchunk@opt[#1]{\setkeys{spelchunk}{#1}\spelchunk@int}
\def\spelchunk@optdisabled[#1]{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\spelchunk@int}
%   This is an internal macro to start the |VerbatimOut| environment
%   embedded in the |spelchunk| environment.
%    \begin{macrocode}
\def\spelchunk@int{%
  \VerbatimEnvironment
  \begin{VerbatimOut}{\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk.tex}}
\def\spelchunk@intdisabled{}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\NewDocumentCommand{\spelchunkatom}{O{}+m}{%
  \ifspel@disabled #2\else%
  \stepcounter{spel@chunk}%
  \spel@idxwrite{chunk}{\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \setkeys{spelchunk}{#1}%
  \makeatletter%
  \scantokens{%
\begin{spelverbatimwrite}{\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk.tex}
#2
\end{spelverbatimwrite}
  }%
  \makeatother%
  \ifspel@chunkarealink%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
         {\input{./\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk}}%
  \else%
    \settowidth\spel@mptboxwidth{\usebox\spel@mptbox}%
    \hspace*{-\spel@mptboxwidth}%
    \hideref{\linksdir/\spel@@optpart\thesubparagraph-\thespel@chunk.\spel@format}
         {\usebox\spel@mptbox}\input{./\chunkdir/\spel@@optpart\thesubparagraph-\thespel@chunk}%
  \fi%
  \spel@chunkarealinkfalse%
  \fi%
}

\def\spelverbatimwrite#1{%
  \@bsphack%
  \openoutputfile{#1}{chunk}%
  \def\verbatim@processline{\addtostream{chunk}{\the\verbatim@line}}%
  \let\do\@makeother\dospecials
  \catcode`\^^M\active \catcode`\^^I=12
  \verbatim@start}%
\def\endspelverbatimwrite{
  \closeoutputstream{chunk}
  \@esphack
}
\def\<<<{\spelchunkatom}
%    \end{macrocode}
%
% \subsubsection{Explicit spelchunks}
%
% \begin{environment}{spelchunkad}
% The |spelchunkad| environment is used to override a previous speech
% chunk. In this way you can provide your own text.
%    \begin{macrocode}
\def\spelchunkad{%
  \catcode`\^^M=\active
  \@ifnextchar[{\catcode`\^^M=5\spelchunk@opt}{\catcode`\^^M=5\spelchunk@int}}
\def\endspelchunkad{%
  \end{VerbatimOut}
  \catcode`\^^M=5\relax
}
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
\AtBeginDocument{
  \newcommand\spel@@optpart{}
}
%    \end{macrocode}
%
% \subsection{Helping the wizard to read our chunks}
%
% \subsubsection{Listing macros that are to be preprocessed}
% \begin{macro}{\spelmacpp}
% Some \LaTeX{} or \TeX commands are only for layout purposes and are
% totally not content related. They do not contribute to what must be
% read. On the contrary, they make it hard for the \spelpl{} parser to
% convert the texts flawlessly to what can be read by the
% text-to-speech engines.
% Examples of these layout-only commands are |\sf|, |\it|, |\tt|,
% |\bf| and |\displaystyle| that are to be discarded, but also macro's
% like e.g. |\fbox| for which only the content is to be retained.
%
% As you might also make your own macros that are pure typesetting
% oriented, it makes sense to provide a macro that registers them as
% pure type-setting macros and use that macro to cover the examples
% mentioned above.
% The command takes four arguments of wich the two middle ones are optional:
% \begin{enumerate}
% \item The name of the macro without leading backslash
% \item The number of arguments of the macro (omit if no arguments, because this is the default value)
% \item The value of the optional first argument (if any, otherwise omit)
% \item The replacement text, using parameter references \#1,
%   \#2, a.s.o. as stamps for where the arguments need to be
%   inserted.
% \end{enumerate}
%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand{\spelmacpp}{moom}
{
  \addtostream{spelidx}{macpp|#1|#2|#3|#4}
}
\ExplSyntaxOff
%    \end{macrocode}
% \end{macro}
%
% Now let's register some standard macros that are to be ignored.
%    \begin{macrocode}
\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]{#1}
\spelmacpp{textit}[1]{#1}
\spelmacpp{texttt}[1]{#1}
\spelmacpp{textbf}[1]{#1}
\spelmacpp{mathbb}[1]{#1}
\spelmacpp{mathcal}[1]{#1}
\spelmacpp{url}[1]{#1}
\spelmacpp{phantom}[1]{}
\spelmacpp{quad}{}
\spelmacpp{qquad}{}
\spelmacpp{displaystyle}{}
\spelmacpp{relax}{}
\spelmacpp{strut}{}
\spelmacpp{mathstrut}{}
\spelmacpp{label}[1]{}
\spelmacpp{-}{}
\spelmacpp{vspace}[1]{}
\spelmacpp{vspace*}[1]{}
\spelmacpp{hspace}[1]{ }
\spelmacpp{hspace*}[1]{ }
%    \end{macrocode}
%
% And let's register a macro for which only the contents is to be
% preserved: 
%    \begin{macrocode}
\spelmacpp{fbox}[1]{#1}
%    \end{macrocode}
%
% \subsubsection{Listing environments that are to be ignored}
% \begin{macro}{\spelenvpp}
% Some \LaTeX{} or \TeX environments are only for layout purposes and are
% totally not content related. They do not contribute to what must be
% read. On the contrary, they make it hard for the \spelpl{} parser to
% convert the texts flawlessly to what can be read by the
% text-to-speech engines.
% An examples of such a layout-only environment is the |center|
% environment. 
%
% As you might also make your own environments that are pure typesetting
% oriented, it makes sense to provide a macro that registers them as
% pure type-setting macros and use that macro to cover the examples
% mentioned above.
%
% The command takes four arguments of wich the two middle ones are optional:
% \begin{enumerate}
% \item The name of the environment
% \item The number of arguments of the environments (omit if no
%   arguments, because this is the default value)
% \item The value of the optional first argument (if any, otherwise omit)
% \item The replacement text, using parameter references \#1,
%   \#2, a.s.o. as stamps for where the arguments need to be
%   inserted. The highest parameter number (one higher than the number
%   of arguments) is for the body of the environment.
% \end{enumerate}
%
%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand{\spelenvpp}{moom}
{
  \addtostream{spelidx}{envpp|#1|#2|#3|#4}
}
\ExplSyntaxOff
%    \end{macrocode}
% \end{macro}
%
% Now let's register some standard macros that are to be ignored:
%    \begin{macrocode}
\spelenvpp{center}{#1}
%    \end{macrocode}
%
% \subsubsection{Audio descriptions for typesetting macros}
% \begin{macro}{\spelmacad}
%   This macro allows specifying how to treat macros (with arguments)
%   that appear in the chunks to read out loud. The arguments are in
%   order: 
%   \begin{enumerate}
%   \item (mandatory) name of the macro (without leading backslash)
%   \item (optional) number of arguments of the macro
%   \item (optional) default for optional (first) argument
%   \item (mandatory) text to read  (with macro parameters in them)
%   You can use the special syntax
%    |@{i18n(keyword,#1,#2)}|
%   to trigger a call to the internationalization (i18n) features built
%   in the \spelpl{} script. This will help to read your commands in an
%   appropriate way. If you miss some features in the i18n list of
%   \spelpl{}, please contact the author to help you out.
%   If you are fluent in Perl, you might also want to change the i18n
%   list of \spelpl{} yourself. It's not that hard.
%   \end{enumerate}
%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand{\spelmacad}{moom}
{
  \addtostream{spelidx}{macad|#1|#2|#3|#4}
}
\ExplSyntaxOff
%    \end{macrocode}
% \end{macro}
%
% We immediately provide some standard constructs, which are to be
% ignored:
%    \begin{macrocode}
\spelmacad{spelatex}{spee-lay-tech}
\spelmacad{spelpl}{spel wizzard dot pl}
\spelmacad{LaTeX}{lay-tech}
\spelmacad{LuaLaTeX}{lua lay-tech}
\spelmacad{TeX}{tech}
\spelmacpp{textsf}[1]{#1}
\spelmacpp{texttt}[1]{#1}
\spelmacpp{textit}[1]{#1}
\spelmacpp{mathit}[1]{\string\text{#1}}
\spelmacpp{emph}[1]{#1}
\spelmacpp{underline}[1]{#1}
\spelmacad{mbox}[1]{#1}
\spelmacad{text}[1]{#1}
\spelmacpp{nobreakspace}{#1}
\spelmacpp{textasciitilde}[1]{ }
\spelmacad{textbackslash}{backslash}
\spelmacad{textsuperscript}[1]{#1}
\spelmacad{footnote}[1]{}
\spelmacad{pm}{@{i18n(plusminus)}}
\spelmacad{ldots}{...}
%    \end{macrocode}
%
% Some more that don't seem ignorable - and they are not indeed - they
% are treated differently by \spelpl{}. However, by registering them
% here, \spelpl{} knows there signature:
%    \begin{macrocode}
\spelmacad{cite}[1]{}
\spelmacad{ref}[1]{}
\spelmacad{pageref}[1]{}
%    \end{macrocode}
%
% \subsubsection{Audio descriptions for typesetting environments}
% \begin{macro}{\spelenvad}
% This macro allows specifying how to treat environments (with arguments)
% that appear in the chunks to read out loud. The arguments are in order:
% \begin{enumerate}
% \item (mandatory) name of the macro (without leading backslash)
% \item (optional) number of arguments of the macro
% \item (optional) default for optional (first) argument
% \item (mandatory) text to read  (with macro parameters in them)
% \end{enumerate}
%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand{\spelenvad}{moomm}
{
  \addtostream{spelidx}{envad|#1|#2|#3|#4|#5}
}
\ExplSyntaxOff
%    \end{macrocode}
% \end{macro}
%
% We immediately provide some standard constructs, which are to be
% ignored:
%    \begin{macrocode}
\spelenvad{center}{}{}
%    \end{macrocode}
%
% \subsubsection{Inline descriptions for nesting}
% \begin{macro}{\spelinlad}
%   This macro incorporates the first argument in the text file, but
%   sends the replacement using a macro preprocessing instruction to the
%   wizard.
%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand{\spelinlad}{mm}{#1}
\spelmacpp{spelinlad}[2]{#2}
\ExplSyntaxOff
%    \end{macrocode}
% \end{macro}
%
% \subsection{Support for third-party  packages}
% We will load the support after the preamble, such that all
% packages have been loaded.
%
% \subsubsection{physics}
%
%    \begin{macrocode}
\AtBeginDocument{
  \@ifpackageloaded{physics}{
    \spelmacad{div}[1]{@{i18n(divergence,#1)}}
    \spelmacad{vec}[1]{@{i18n(vector,#1)}}
    \spelmacad{curl}[1]{@{i18n(curl,#1)}}
    \spelmacad{grad}[1]{@{i18n(gradient,#1)}}
    \spelmacad{dv}[2]{@{i18n(derivative,#1,#2)}}
    \spelmacad{pdv}[2]{@{i18n(partialderivative,#1,#2)}}
  }  
  {}
}
%    \end{macrocode}
%
% \subsection{Extra math commands}
%
% The commands are only loaded if the package option |extramath| is
% provided: 
%
%    \begin{macrocode}
\ifspel@extramath
%    \end{macrocode}
%
% \begin{macro}{\setenum}
% This macro typesets a set defined by enumeration:
%    \begin{macrocode}
\DeclareRobustCommand{\setenum}[1]{\left\{#1\right\}}
\spelmacad{setenum}[1]{@{i18n(Setenum,#1)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setdesc}
% This macro typesets a set defined by description:
%    \begin{macrocode}
\DeclareRobustCommand{\setdesc}[1]{\left\{#1\right\}}
\spelmacad{setdesc}[1]{@{i18n(Setdesc,#1)}}
%    \end{macrocode}
% \end{macro}
%
% Note that these two macro's are identical! However, the fact that
% they have a different name is of great value to \spelpl{}.
%
% \begin{macro}{\unitof}
%   This macro typeets its argument between square brackets, meaning
%   'the unit of'. The corresponding audiodescription takes care of
%   proper reading out loud this construct. 
%    \begin{macrocode}
\DeclareRobustCommand{\unitof}[1]{\left[#1\right]}
\spelmacad{unitof}[1]{@{i18n(Unitof,#1)}}
%    \end{macrocode}
% \end{macro}
%
% The conditional loading ends here:
%    \begin{macrocode}
\fi
%    \end{macrocode}
% 
% \iffalse
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \fi
%
% \section{TODO}
% \begin{spelchunk}[arealink]
%   As long as there are things on our todo list, we have a reason to
%   live.
% \end{spelchunk}
% \begin{itemize}
%   \spelitem{provide enable/disable switch to disable certain ranges in
%   text, e.g. the implementation range in this document}
%   \spelitem{enable bibliography and citation stuff}
% \end{itemize}
%
% \bibliographystyle{alpha}
%
% \begin{thebibliography}{99}
%
% \bibitem{NVDA}
% NVDA from NV Access, empowering lives through non-visual access to technology
% \newblock \url{https://www.nvaccess.org}
% \newblock online, accessed in June 2024.
%
% \bibitem{SPRINT}
% SprintPlus, helping people with dyslexia
% \newblock \url{https://www.sprintplus.be/en}
% \newblock online, accessed in June 2024.
%
% \bibitem{ADOBEREADER}
% Adobe Reader, a PDF reader from Adobe.
% \newblock \url{https://get.adobe.com/}
% \newblock online, accessed in May 2024.
%
% \bibitem{TAGPDF}
% TagPDF - Tools for experimenting with tagging using pdfLaTeX and
% LuaLaTeX.
% \newblock \url{https://ctan.org/pkg/tagpdf}
% \newblock online, accessed in June 2024.
%
% \bibitem{WINE}
% Wine - Wine Is Not an Emulator - running windows applications on POSIX-compliant systems.
% \newblock \url{https://www.winehq.org}
% \newblock online, accessed in June 2024.
%
% \bibitem{SPEL}
% SpeL --- Speech-enabled \LaTeX.
% \newblock \url{https://ctan.org/pkg/spel}
% \newblock online, accessed in June 2024.
%
% \bibitem{SPELWIZARD}
% SpeL::Wizard --- Incantating \LaTeX{} into natural lanuage
% \newblock \url{https://metacpan.org/pod/SpeL::Wizard}
% \newblock online, accessed in June 2024.
%
% \bibitem{FESTIVAL} 
% The Festival TTS-program.
% \newblock \url{http://www.cstr.ed.ac.uk/projects/festival}.
% \newblock online, accessed in May 2024.
%
% \bibitem{BALABOLKA} 
% The Balabolka TTS-program.
% \newblock \url{http://www.cross-plus-a.com/balabolka.htm}.
% \newblock online, accessed in May 2024.
%
% \bibitem{FREETTS}
% FreeTTS --- A speech synthesizer in Java.
% \newblock \url{https://freetts.sourceforge.io/docs/index.php}.
% \newblock online, accessed in May 2024.
%
% \bibitem{AWSPOLLY}
% Amazon Polly --- An online text-to-speech engine.
% \newblock \url{https://aws.amazon.com/polly}
% \newblock online, accessed in May 2024.
%
% \bibitem{CTAN} 
% The Comprehensive \TeX{} Archive Network.
% \newblock \url{http://www.ctan.org}.
% \newblock online, accessed in May 2024.
%
% \bibitem{CPAN} 
% The Comprehensive Perl Archive Network.
% \newblock \url{http://www.cpan.org}.
% \newblock online, accessed in May 2024.
%
% \bibitem{XPDF}
% xpdf, a simple and very fast PDF reader on \GNU/Linux.
% \newblock \url{http://www.xpdfreader.com/}.
% \newblock online, accessed in May 2024.
%
% \bibitem{EVINCE}
% evince, a PDF reader, part of the Gnome environment.
% \newblock \url{https://help.gnome.org/users/evince/stable/}.
% \newblock online, accessed in May 2024.
%
% \bibitem{OKULAR}
% okular, a PDF reader, part of the KDE environment.
% \newblock \url{https://okular.kde.org}.
% \newblock online, accessed in May 2024.
%
% \end{thebibliography}
%
% \Finale
\endinput
