% \iffalse                                                 -*- mode: LaTeX -*-
%
% fixme.dtx --- Doc file for the FiXme package (code and documentation)
%
% Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Didier Verna.
% Copyright (C) 2007, 2009 Didier Verna.
%
% Author:        Didier Verna <didier@lrde.epita.fr>
% Maintainer:    Didier Verna <didier@lrde.epita.fr>
% Created:       Thu Dec 10 16:04:01 1998
% Last Revision: Thu Jul 16 19:55:00 2009
%
% This file is part of FiXme.
%
% FiXme may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.1
% 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.1 or later is part of all distributions of LaTeX
% version 1999/06/01 or later.
%
% FiXme consists of the files listed in the file `README'.
%
%
% Commentary:
%
% Contents management by FCM version 0.1.
%
%
% Code:
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
% \OnlyDescription
% \CodelineIndex
% \RecordChanges
\begin{document}
\DocInput{fixme.dtx}
\end{document}
%</driver>
%
% \fi
%
% \catcode`\¡=14
% \CheckSum{880}
%% \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         \~}
%
% \newcommand\version{3.4}
% \newcommand\releasedate{2009/07/16}
% \newcommand\packagecopyright{Copyright \copyright{} 1998, 1999, 2000, 2001,
%   2002, 2004, 2005, 2006, 2007, 2009 Didier Verna}
% \newcommand\fixme{\textsf{FiXme}}
% \newcommand\auctex{AUC-\TeX}
% \MakeShortVerb{\|}
% \date\today
% \title{\fixme{} -- a \LaTeXe{} package for inserting fixme notes
%   in your documents\thanks{This document describes \fixme{} \version,
%     release date \releasedate.}}
% \author{Didier Verna\\
%   \texttt{mailto:didier@lrde.epita.fr}\\
%   \texttt{http://www.lrde.epita.fr/\~{}didier/}}
% \maketitle
%
%
% \begin{abstract}
%   In the process of writing a long document, it is a common practice to
%   leave some parts unwritten or uncomplete, and come back to them later. In
%   such cases, you probably want to stick clues about which parts need to be
%   ``fixed'', where they are located, and what needs to be done. This is what
%   I call ``fixme notes''. The purpose of this package is to provide you with
%   convenient ways to insert \fixme{} notes in your documents.\par
%   The \fixme{} package is \packagecopyright{}, and distributed under the
%   terms of the LPPL license.
% \end{abstract}
%
%
% \section{Description}
% With \fixme, you can insert different kinds of notes in your documents,
% ranging from simple not-so-important notices to critical stuff that must
% absolutely be fixed in the final version.\par
% \fixme{} gives you full control on the layout of these notes: they can be
% displayed inline (directly in the text), as marginal paragraphs (the
% default), as footnotes and even as index entries. All these possibilities
% can be mixed together. Additionally, you can summarize all \fixme{} notes in
% a ``list of fixme's''.\par
% \fixme{} notes are also recorded in the log file, and (depending on their
% importance level) some of them are displayed on the terminal during
% compilation. A final summary is also created at the end of the compilation
% process.\par
% All these features are actually available when you're working in
% \texttt{draft} mode. In \texttt{final} mode, the behavior is slightly
% different: any remaining critical note generates an error (the compilation
% aborts), while non critical ones are just removed from the document's body
% (they're still recorded in the log file though).
%
%
% \section{Using \fixme}
% First of all, please note that the \texttt{ifthen} and \texttt{verbatim}
% packages are required. You don't have to load them explicitly though. As
% long as \LaTeXe{} can locate them, they will be used automatically.\par
% To use \fixme, simply say |\usepackage[|\meta{options}|]{fixme}| in the
% preamble of your document.
%
% \subsection{Inserting notes}
% \subsubsection{Macros}
% \DescribeMacro{\fixme}
% The main command for inserting a \fixme{} note in your document is the
% |\fixme| macro. It takes the note to insert as its mandatory argument. Notes
% inserted via this command are considered fatal to your document's final
% processing (see section \ref{sec:behavior}).\par
% \DescribeMacro{\fxnote}
% \DescribeMacro{\fxwarning}
% \DescribeMacro{\fxerror}
% As of version 2.0, \fixme{} provides three new macros that insert
% meta-comments about the document, rather than real fixmes. These
% comments have three different importance levels: note, warning and (non
% critical) error. The corresponding macros obey the same syntax as |\fixme|.
% However, none of the notes inserted via these macros are fatal.
%
% \subsubsection{Environments}
% \DescribeEnv{anfxnote}
% \DescribeEnv{anfxwarning}
% \DescribeEnv{anfxerror}
% \DescribeEnv{afixme}
% As of version 3.0, \fixme{} provides environments for inserting longer
% notes. These environments take one optional argument (should be short,
% perhaps a summary of the note) that will be used in the list of fixme's and
% in the index if required.\par
% The \fixme{} environments behave exactly the same way as their macro
% counterpart, except for the layout (see section \ref{sec:layout}): as they
% are meant for longer notes, the layout is always \texttt{inline}. The
% \texttt{index} and \texttt{marginclue} layouts are still honored however. By
% default, \fixme{} environments are typeset in a \texttt{quotation} one.
%
% \subsection{Controlling the behavior of \fixme\label{sec:behavior}}
% \DescribeEnv{final}
% \DescribeEnv{draft}
% The global behavior of the package is controlled via the two standard
% options \texttt{final} and \texttt{draft}. These options are usually given
% to |\documentclass{}| which in turn passes them to all packages.\par
% In \texttt{draft} mode, the notes are recorded in the log file, and
% appear in the text as specified by the layout settings (see section
% \ref{sec:layout}). Additionally, warnings, errors and fatal errors are also
% displayed on the terminal.\par
% In final mode, non fatal notes (those generated by the |\fx*| commands or by
% the |anfx*| environments) are still logged, but they're not typeset. On the
% other hand, any remaining fatal note (generated by the |\fixme| command or
% the |afixme| environment) will throw a \LaTeX{} error and thus interrupt or
% abort compilation with an informative message. This will help you track down
% forgotten important caveats in your document. Let me say it again: final
% documents can only have notes, warnings, and (non critical) errors left.
% Well, if, for some reason, you really want to compile in \texttt{final}
% mode with critical \fixme{} notes left behind, you always have the
% possibility to pass the \texttt{draft} option to \fixme{} directly\ldots\par
% The \texttt{final} mode has been chosen as the default because \LaTeXe{}
% itself behaves this way.\par
%
% \subsection{Controlling the notes layout\label{sec:layout}}
% \fixme{} notes can appear in several forms (that can be combined) in your
% document.
% \subsubsection{Global layout}
% \DescribeEnv{inline}
% \DescribeEnv{margin}
% \DescribeEnv{marginclue}
% \DescribeEnv{footnote}
% \DescribeEnv{index}
% The layout forms currently supported are: inline (directly in the text),
% marginal notes, marginal clues (see below), footnotes, and index entries. To
% activate a particular layout globally (that is, for the whole document), use
% the corresponding package option. By default, only the \texttt{margin}
% layout is active.\par
% Each layout option has a counterpart that deactivates it. The counterpart
% option has the same name, prefixed with \texttt{no}. For instance, if you
% don't want marginal notes, use the \texttt{nomargin} option.\par
% Finally, note that \fixme{} environments behave in a special way: they are
% always typeset \texttt{inline}, regardless of your layout settings (they
% respect your wish for index and marginal clues though).\par
%
% \subsubsection{Marginal Clues}
% Sometimes, marginal notes are too narrow for what you want to put in them,
% so you would switch to an inline or a footnote layout. But then, it is more
% difficult to keep track of the \fixme{} note's location on the page.\par
% As of version 3.2, \fixme{} provides a special layout called ``marginal
% clue'' to help locating the notes: a marginal clue does not display the
% note's contents, but only an indication that there is a note at that place.
% So you have to use another layout form (typically inline or footnote) in
% order to get the actual contents.\par
% Obviously, \texttt{margin} and \texttt{marginclue} are mutually exclusive.
% If you try to activate both, only the most recently activated form will be
% enabled (and you'll get a notice in the compilation log).
%
% \subsubsection{Local Layout}
% \DescribeMacro{\fixme[]}
% \DescribeMacro{\fxnote[]}
% \DescribeMacro{\fxwarning[]}
% \DescribeMacro{\fxerror[]}
% As of version 3.0, \fixme{} provides a way to change the selected layout(s)
% on a per-note basis: each note insertion command takes an optional first
% argument that overrides the global layout. This argument consists of one or
% more layout options (\texttt{inline}, \texttt{margin}, \texttt{marginclue},
% \texttt{footnote} and \texttt{index}) separated by commas. Remember that
% local layouts \emph{override} the global ones; they don't add to it.\par
% On what occasion would one want to modify the layout for a particular note~?
% Here is a typical situation: suppose you have a document in which \fixme{}
% notes are typeset as margin paragraphs (this is the default). You would not
% be able to put a note in a figure, because floats can't be nested in
% \LaTeX{} (margin paragraphs are floats). In such a case, you would rather
% inline the note, which can be done with something like
% |\fixme[inline]{blah}|.\par
%
% \subsubsection{Class compatibility}
% By default, \fixme{} is set to use marginal notes. You should know that this
% is known to cause problems with at least the ACM SIG classes:
% \texttt{acm\_proc\_article-sp} and \texttt{sig-alternate}. These classes
% forbid the use of |\marginpar|, so if you use them, you should choose
% another layout for \fixme{}, and also avoid using marginal clues\ldots
%
% \subsection{Controlling the notes logging}
% \DescribeEnv{silent}
% \DescribeEnv{nosilent}
% As well as being displayed in the document itself, all \fixme{} notes are
% ``logged'' in different ways: by default, simple notes are recorded in the
% log file while the others are also displayed on the terminal output.\par
% You have the ability to suppress all kind of logging by using the
% \texttt{silent} option. By default, the behavior is that of
% \texttt{nosilent}.
%
% \subsection{List of \fixme's}
% \DescribeMacro{\listoffixmes}
% \fixme{} remembers where you put \fixme{} notes in a toc-like file whose
% extension is \texttt{lox}. The |\listoffixmes| macro generates the list of
% all \fixme{} notes in a manner similar to that of the ``list of figures''
% for instance. A standard layout is automatically used for the `article',
% `report', `book' classes and their koma-script replacements. If another
% class is used, the `article' layout is selected. Also, note that if no
% \fixme{} note remain in the document, this macro doesn't generate an empty
% list, but rather stays silent. It also stays silent in \texttt{final} mode,
% regardless of the presence of remaining notes.
%
%
% \section{Customizing \fixme}
% \subsection{Customizing the notes layout}
% \subsubsection{Macros}
% The \texttt{inline}, \texttt{margin} and \texttt{footnote} layouts have two
% parts: a ``prefix'' which depends on the note level, and the note
% itself. The prefix is one of ``\fixme{} note:'', ``\fixme{} warning:'',
% ``\fixme{} error:''  or simply ``\fixme{}:'', and appears in bold. The note
% itself appears emphasized.
% \DescribeMacro{\FXInline}
% \DescribeMacro{\FXMargin}
% \DescribeMacro{\FXFootnote}
% These layouts are implemented thanks to the corresponding |\FX*| macros that
% you can redefine if you wish. Each such macro takes two mandatory
% arguments: the prefix and the note, in that order.\par
% \DescribeMacro{\FXMarginCLue}
% The special \texttt{marginclue} layout only outputs the prefix mentioned
% above. Its layout is controlled by the macro |\FXMarginClue| which takes the
% prefix as its only mandatory argument.
% \DescribeMacro{\FXIndex}
% The |\FXIndex| macro is used for the \texttt{index} layout. All \fixme{}
% index entries appear under the ``\fixme{}'' key in the symbols section.
% There are 4 subcategories under this key, as many as there are note levels.
% By default, only the first 3 of them are used though (fatal errors do not
% appear under a subkey, but directly under the \fixme{} key). The notes are
% numbered in the index.\par
%
% \subsubsection{Environments}
% \DescribeMacro{\FXEnvBegin}
% \DescribeMacro{\FXEnvEnd}
% The optional argument of \fixme{} environments is always typeset according
% to the \texttt{inline} layout described above. By default, \fixme{} uses a
% \texttt{quotation} for displaying the environments'contents. If you want to
% change that, you can redefine the macros |\FXEnvBegin| and |\FXEnvEnd| that
% open and close the environments.
%
% \subsection{Customizing the notes logging}
% \DescribeMacro{\FXNote}
% \DescribeMacro{\FXWarning}
% \DescribeMacro{\FXError}
% \DescribeMacro{\FXFatal}
% If you want a finer control on logging, you can redefine the commands used
% to implement it. These commands (on the left) are the ones used by
% |\fxnote|, |\fxwarning|, |\fxerror| and |\fixme| respectively. They take the
% note itself as mandatory argument.
%
% \subsection{Fancy fruit salad layout}
% \DescribeEnv{user}
% \DescribeMacro{\FXUser}
% If, for some totally unjustified reason, you are not happy with the
% available layouts, you have the ability to define your own: pass the
% \texttt{user} option to the package (it also has its \texttt{nouser}
% counterpart), and define an |\FXUser| macro in the following manner:\\
% |\newcommand{\FXUser}[2]{|\meta{fancy fruit salad layout job}|}|\\ The
% arguments are the prefix, and the note itself, in that order.\par
% Note that the \texttt{user} option can also be used in the optional argument
% of the notes insertion commands.
%
% \subsection{Internationalization}
% \DescribeEnv{english}
% \DescribeEnv{french}
% \DescribeEnv{francais}
% \DescribeEnv{spanish}
% \DescribeEnv{italian}
% \DescribeEnv{german}
% \DescribeEnv{ngerman}
% \DescribeEnv{danish}
% \DescribeEnv{croatian}
% \fixme{} currently supports English, French, Spanish, Italian, German,
% Danish and Croatian. You can select the language you want to use by passing
% the corresponding option (these options are usually given directly to
% |\documentclass{}| which in turn passes them to all packages). The
% \texttt{french} and \texttt{francais} options are synonyms. The
% \texttt{german} and \texttt{ngerman} options are currently equivalent.\par
% If you want a finer grain on the language-dependent parts of \fixme{}, the
% following macros are provided and can be redefined.\par
% \DescribeMacro{\fixmenoteprefix}
% \DescribeMacro{\fixmewarningprefix}
% \DescribeMacro{\fixmeerrorprefix}
% \DescribeMacro{\fixmefatalprefix}
% \DescribeMacro{\fixmelogo}
% The |\fixme*prefix| macros define the prefix for the four different note
% levels. They make intensive use of the macro |\fixmelogo| ;-)\par
% \DescribeMacro{\fixmeindexname}
% \DescribeMacro{\fixmenoteindexname}
% \DescribeMacro{\fixmewarningindexname}
% \DescribeMacro{\fixmeerrorindexname}
% \DescribeMacro{\fixmefatalindexname}
% The macro |\fixmeindexname| defines the main \fixme{} index key. The other
% ones define the different index subkeys for each note level. Please note that
% an empty name for a subkey means that you don't actually want a subcategory
% (that's the case by default for fatal errors). The corresponding notes will
% then appear directly under the main \fixme{} key. For that reason, a non
% empty subkey must end with an exclamation mark.\par
% \DescribeMacro{\listfixmename}
% |\listfixmename| defines the title for the ``list of fixmes'' section.
%
% ^^A\subsection{Counters}
% ^^A \DescribeMacro{\thefixmecount}
% ^^A \DescribeMacro{\thefixmenotecount}
% ^^A \DescribeMacro{\thefixmewarningcount}
% ^^A \DescribeMacro{\thefixmeerrorcount}
% ^^A \DescribeMacro{\thefixmefatalcount}
% ^^A As of \fixme{} version 2.0, four counters are provided. They count
% ^^A respectively the total number of \fixme{} notes, and the number of
% ^^A level-specific ones. At the end of processing, a \fixme{} usage summary is
% ^^A displayed and logged.
%
%
% \section{\auctex{} support}
% \auctex{} is a powerful major mode for editing \TeX{} documents in
% \textsf{Emacs} or \textsf{XEmacs}. In particular, it provides automatic
% completion of macro names once they are known. \fixme{} supports \auctex{}
% by providing a style file named \texttt{fixme.el} which contains \auctex{}
% definitions for the relevant macros. This file should be installed in a
% place where \auctex{} can find it (usually in a subdirectory of your
% \LaTeX{} styles directory). Please refer to the \auctex{} documentation for
% more information on this.
%
% \section{Changes}
% \begin{itemize}
% \item[v3.4] |\fixme|, |\fxerror|, |\fxwarning| and |\fxnote| are now robust,
%   thanks to Will Robertson.\\
%   Fix incompatibility with KOMA-Script classes version of |\@starttoc| when
%   the lox file is inexistent, reported by Philipp Stephani.
% \item[v3.3] Document incompatibility between marginal layout and the ACM
%   SIG classes, reported by Jochen Wuttke.\\
%   Honor \texttt{twoside} option in marginal layout, suggested by Jens
%   Remus.\\
%   Support for KOMA-Script classes version 2006/07/30 v2.95b,
%   suggested by Jens Remus.\\
%   Documentation improvements suggested by Brian van den Broek.\\
%   Fix incompatibility with \texttt{amsart} reported by Lars Madsen:
%   \cs{@starttoc} takes two arguments.\\
%   Fix bug reported by Stefan Mann: a typo in the |\fixme@footnotetrue| macro
%   name.
% \item[v3.2] Added the marginclue layout option which only signals a fixme in
%   the margin, withtout the actual contents.\\
%   Support for Croatian thanks to Marcel Maretic |<marcel@fsb.hr>|.\\
%   Fix incompatibility with \texttt{amsbook} reported by Claude
%   Lacoursi\`ere: \cs{@starttoc} takes two arguments.\\
%   Fix incompatibility with Beamer reported by Akim Demaille: protect
%   contents of lox file.
% \item[v3.1] Fix bug reported by Arnold Beckmann: the environments were
%   visible in final mode.
% \item[v3.0] Added environments corresponding to the note insertion
%   commands.\\
%   Added an optional first argument to the note insertion commands
%   to change the layout locally.\\
%   Fix bug reported by Akim Demaille: marginal notes could mess up the
%   document's layout by flushing it right.
% \item[v2.2] New option \texttt{silent} to suppress notes logging.\\
%   Support for Danish thanks to Kim Rud Bille |<krbi01@control.auc.dk>|.
% \item[v2.1] Use |\nobreakspace| instead of the tilda character. This avoids
%   conflicts with Babel in Spanish environments.\\
%   Fix bug reported by Knut Lickert: index entries were unconditionally built.
% \item[v2.0] New feature: note levels.\\
%   New feature: \fixme{} note counters and usage summary.\\
%   Suggestions from Kasper B. Graversen |<kbg@dkik.dk>|.\\
%   Support for Spanish thanks to Agust\'in Mart\'in |<agusmba@terra.es>|
% \item[v1.5] New appearance option: \texttt{inline}.
% \item[v1.4] Support for the koma-script classes.\\
%   Fix bug reported by Ulf Jaenicke-Roessler: the |\listoffixmes| command
%   didn't work when called before the first \fixme{} note.
% \item[v1.3] Support for Italian thanks to Riccardo Murri
%   |<murri@phc.unipi.it>|.
% \item[v1.2] Support for German thanks to Harald Harders
%   |<h.harders@tu-bs.de>|.
% \end{itemize}
%
% \StopEventually{\par Well, I think that's it. Enjoy using \fixme{}!
%   \vfill\hfill\small \packagecopyright{}.}
%
% \section{The Code}
% \begin{macro}{\fixmelogo}
%   Here's the preamble:
% \end{macro}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fixme}[2009/07/16 v3.4
			Insert fixme notes in your documents]

\RequirePackage{ifthen}
\RequirePackage{verbatim}

\newcommand*\fixmelogo{\textsf{FiXme}}

%    \end{macrocode}
% \subsection{List macros}
% \begin{macro}{\listoffixmes}
%   \begin{macro}{\listoffixmes@final}
%     \begin{macro}{\listoffixmes@draft}
%       |\listoffixmes| is empty by default. The |final| or |draft| options
%       will provide the proper definition. Lists are output in a document
%       class dependant fashion. Classes currently recognized are article,
%       report, book and their koma-script replacements.
%
%       In order to prevent the List of Fixme's heading from being generated
%       when there are no fixmes, a test on the existence of the lox file is
%       performed. There's a slight bug left however: after removing the last
%       fixme, one ends up with an empty lox file, so the heading still
%       appear. Previously, this was done by checking if some fixmes were
%       given, but that was buggy: the list of fixme's could not appear before
%       the first fixme note\ldots I should try to detect whether the file is
%       empty.
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\let\l@fixme\l@figure
\newcommand\listoffixmes{}
\def\listoffixmes@final{}
\def\listoffixmes@draft{%
  \IfFileExists{\jobname .lox}{%
    \@listoffixmes@pretoc%
    \@starttoc{lox}%
    \@listoffixmes@posttoc}{%
    \@starttoc{lox}}}

%    \end{macrocode}
% The \texttt{amsbook} and \texttt{amsart} classes have the very ugly idea of
% redefining the \cs{@starttoc} command to take two arguments. Therefore, I
% need to provide a specific version of the \cs{listoffixmes} macro:
%    \begin{macrocode}
\def\listoffixmes@draft@ams{\@starttoc{lox}\listfixmename}

%    \end{macrocode}
% \begin{macro}{\listfixmename}
%   In order to redefine the list title, users have to call |\renewcommand|.
%   I don't like this much: it would be cleaner to provide a real command
%   that redefines the title internally. However, I'll stick with the
%   current scheme because it is consistent with the rest of \LaTeXe's lists.
% \end{macro}
%    \begin{macrocode}
\newcommand*\listfixmename{}

%    \end{macrocode}
%
% \subsubsection{Standard classes}
% \begin{macro}{\listoffixmes@pretoc@article}
%   \begin{macro}{\listoffixmes@posttoc@article}
%     Let's start with the article version:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@listoffixmes@pretoc@article{%
  \section*{\listfixmename%
    \@mkboth{\MakeUppercase\listfixmename}{\MakeUppercase\listfixmename}}%
  }
\def\@listoffixmes@posttoc@article{}

%    \end{macrocode}
% \begin{macro}{\listoffixmes@pretoc@report}
%   \begin{macro}{\listoffixmes@posttoc@report}
%     Here's the report version:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@listoffixmes@pretoc@report{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \chapter*{\listfixmename%
    \@mkboth{\MakeUppercase\listfixmename}{\MakeUppercase\listfixmename}}%
  }
\def\@listoffixmes@posttoc@report{\if@restonecol\twocolumn\fi}

%    \end{macrocode}
% \begin{macro}{\listoffixmes@pretoc@book}
%   \begin{macro}{\listoffixmes@posttoc@book}
%     And here's the book version:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@listoffixmes@pretoc@book{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \chapter*{\listfixmename%
    \@mkboth{\MakeUppercase\listfixmename}{\MakeUppercase\listfixmename}}%
  }
\def\@listoffixmes@posttoc@book{\if@restonecol\twocolumn\fi}

%    \end{macrocode}
%
% \subsubsection{koma-script classes}
% The code below (version 3.3) mimics KOMA-Script version 2006/07/30 v2.95b.
% Older versions (using chapter*) are no longer supported because it is
% simpler that way, but if some people complain, I'll  have to conditionalize
% on the KOMA-Script version, which would be a PITA.
%    \begin{macrocode}
\newcommand*\lox@heading{\float@listhead{\listfixmename}}

%    \end{macrocode}
% \begin{macro}{\listoffixmes@pretoc@scrartcl}
%   \begin{macro}{\listoffixmes@posttoc@scrartcl}
%     Let's start with the scrartcl version:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@listoffixmes@pretoc@scrartcl{%
  \begingroup%
    \lox@heading%
    \setparsizes{0}{0}{\z@\@plus 1fil}\par@updaterelative
  }
\def\@listoffixmes@posttoc@scrartcl{%
  \endgroup
  }

%    \end{macrocode}
% \begin{macro}{\listoffixmes@pretoc@scrreprt}
%   \begin{macro}{\listoffixmes@posttoc@scrreprt}
%     Here's the scrreprt version:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@listoffixmes@pretoc@scrreprt{%
  \begingroup%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \lox@heading%
    \setparsizes{0}{0}{\z@\@plus 1fil}\par@updaterelative
  }
\def\@listoffixmes@posttoc@scrreprt{%
    \if@restonecol\twocolumn\fi
  \endgroup
  }

%    \end{macrocode}
% \begin{macro}{\listoffixmes@pretoc@scrbook}
%   \begin{macro}{\listoffixmes@posttoc@scrbook}
%     And here's the scrbook version:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@listoffixmes@pretoc@scrbook{%
  \begingroup%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \lox@heading%
    \setparsizes{0}{0}{\z@\@plus 1fil}\par@updaterelative
}
\def\@listoffixmes@posttoc@scrbook{%
    \if@restonecol\twocolumn\fi
  \endgroup
}

%    \end{macrocode}
%
% \subsection{Layout macros}
% \begin{macro}{\FXInline}
%   \begin{macro}{\FXMargin}
%     \begin{macro}{\FXMarginCLue}
%       \begin{macro}{\FXFootnote}
%         The macros to implement different layouts for the fixme notes:
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand\FXInline[2]{%
  \textbf{#1}: \emph{#2}}
\newcommand\FXMargin[2]{%
  \marginpar[\footnotesize\raggedleft\textbf{#1}: \emph{#2}]{%
    \footnotesize\raggedright\textbf{#1}: \emph{#2}}}
\newcommand\FXMarginClue[1]{%
  \marginpar[\footnotesize\raggedleft\textbf{#1}~!]{%
    \footnotesize\raggedright\textbf{#1}~!}}
\newcommand\FXFootnote[2]{%
  \footnote{\textbf{#1}: \emph{#2}}}

%    \end{macrocode}
% \begin{macro}{\fixmeindexname}
%   \begin{macro}{\FXIndex}
%     The macros for index generation:
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fixmeindexname{}
\newcommand\FXIndex[1]{%
  \index{***@\fixmeindexname:!#1}}

%    \end{macrocode}
% \begin{macro}{\fixmefatalprefix}
% \begin{macro}{\FiXmeInline}
%   \begin{macro}{\FiXmeMargin}
%     \begin{macro}{\FiXmeFootnote}
%       \begin{macro}{\FiXmeUser}
%         \begin{macro}{\FiXmeIndex}
%           \begin{macro}{\FiXmeInfo}
%             \begin{macro}{\FiXmeWarning}
%               Apart from |\fixmefatalprefix|, the following macros are kept
%               only to preserve backward compatibility. They are used only by
%               critical notes and are made to call the new versions by
%               default:
%             \end{macro}
%           \end{macro}
%         \end{macro}
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fixmefatalprefix{}
\newcommand\FiXmeInline[1]{\FXInline{\fixmefatalprefix}{#1}}
\newcommand\FiXmeMargin[1]{\FXMargin{\fixmefatalprefix}{#1}}
\newcommand\FiXmeFootnote[1]{\FXFootnote{\fixmefatalprefix}{#1}}
\newcommand\FiXmeUser[1]{}
\let\FiXmeUser\empty

\newcommand\FiXmeIndex[1]{\FXIndex{#1}}
\newcommand\FiXmeInfo[1]{}
\newcommand\FiXmeWarning[1]{}

%    \end{macrocode}
% Booleans that control which layouts are selected:
%    \begin{macrocode}
\newif\iffixme@inline
\newif\iffixme@margin
\newif\iffixme@marginclue
\newif\iffixme@footnote
\newif\iffixme@user
\newif\iffixme@index

%    \end{macrocode}
% Setters for these booleans (some might required special treatment):
%    \begin{macrocode}
\let\fixme@setinline\fixme@inlinetrue
\def\fixme@setmargin{%
  \iffixme@marginclue%
    \PackageWarning{FiXme}{%
      Marginal notes requested; turning marginal clues off}%
    \fixme@margincluefalse%
  \fi%
  \fixme@margintrue}
\def\fixme@setmarginclue{%
  \iffixme@margin%
    \PackageWarning{FiXme}{%
      Marginal clues requested; turning marginal notes off}%
    \fixme@marginfalse%
  \fi%
  \fixme@margincluetrue}
\let\fixme@setfootnote\fixme@footnotetrue
\let\fixme@setuser\fixme@usertrue
\let\fixme@setindex\fixme@indextrue

%    \end{macrocode}
% \begin{macro}{\fixme@text}
%   This macro implements the common (textual) part of all notes:
% \end{macro}
%    \begin{macrocode}
\def\fixme@text#1#2{%
  \iffixme@inline\FXInline{#1}{#2}\fi%
  \iffixme@margin\FXMargin{#1}{#2}\fi%
  \iffixme@marginclue\FXMarginClue{#1}\fi%
  \iffixme@footnote\FXFootnote{#1}{#2}\fi%
  \iffixme@user\FXUser{#1}{#2}\fi}

%    \end{macrocode}
% Options that control which layouts are selected:
%    \begin{macrocode}
\DeclareOption{inline}{\fixme@setinline}
\DeclareOption{noinline}{\fixme@inlinefalse}
\DeclareOption{margin}{\fixme@setmargin}
\DeclareOption{nomargin}{\fixme@marginfalse}
\DeclareOption{marginclue}{\fixme@setmarginclue}
\DeclareOption{nomarginclue}{\fixme@margincluefalse}
\DeclareOption{footnote}{\fixme@footnotetrue}
\DeclareOption{nofootnote}{\fixme@footnotefalse}
\DeclareOption{user}{\fixme@usertrue}
\DeclareOption{nouser}{\fixme@userfalse}
\DeclareOption{index}{\fixme@indextrue}
\DeclareOption{noindex}{\fixme@indexfalse}

%    \end{macrocode}
% The following options are here for backward compatibility, but are not used
% anymore:
%    \begin{macrocode}
\DeclareOption{info}{}
\DeclareOption{noinfo}{}
\DeclareOption{warning}{}
\DeclareOption{nowarning}{}

%    \end{macrocode}
%
% \subsection{Logging macros}
% \begin{macro}{\FXNote}
%   \begin{macro}{\FXWarning}
%     \begin{macro}{\FXerror}
%       \begin{macro}{\FXFatal}
%         The macros forcontrolling logging (log file and terminal output):
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand\FXNote[1]{%
  \GenericInfo{%
    (FiXme)\@spaces\@spaces\@spaces\@spaces}{%
    Package FiXme Note: `#1'}}
\newcommand\FXWarning[1]{%
  \PackageWarning{FiXme}{`#1'}}
\newcommand\FXError[1]{%
  \GenericWarning{%
    (FiXme)\@spaces\@spaces\@spaces\@spaces}{%
    Package FiXme Error: `#1'}}
\newcommand\FXFatal[1]{%
  \GenericWarning{%
    (FiXme)\@spaces\@spaces\@spaces\@spaces}{%
    Package FiXme: `#1'}}

%    \end{macrocode}
% Boolean that control wether to stay silent or not:
%    \begin{macrocode}
\newif\iffixme@silent

%    \end{macrocode}
%% Options that control whether to be silent or not:
%    \begin{macrocode}
\DeclareOption{silent}{\fixme@silenttrue}
\DeclareOption{nosilent}{\fixme@silentfalse}

%    \end{macrocode}
%
% \subsection{\fixme{} notes}
% Here are the counters:
% \DescribeMacro{\thefixmecount}
% \DescribeMacro{\thefixmenotecount}
% \DescribeMacro{\thefixmewarningcount}
% \DescribeMacro{\thefixmeerrorcount}
% \DescribeMacro{\thefixmefatalcount}
%    \begin{macrocode}
\newcounter{fixmecount}
\newcounter{fixmenotecount}
\newcounter{fixmewarningcount}
\newcounter{fixmeerrorcount}
\newcounter{fixmefatalcount}

%    \end{macrocode}
% \begin{macro}{\fixmenoteprefix}
%   \begin{macro}{\fixmenoteindexname}
%     \begin{macro}{\fixme@note@draft}
%       \begin{macro}{\fixme@note@final}
%         The different flavors of fixme notes. Proper definitions will be
%         selected by the |draft| or |final| options. Let's start with the
%         note notes:
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fixmenoteprefix{}
\newcommand*\fixmenoteindexname{}
\def\fixme@note@draft#1{%
  \fixme@text{\fixmenoteprefix}{#1}%
  \iffixme@index\FXIndex{\fixmenoteindexname\thefixmenotecount: #1}\fi%
  \iffixme@silent\else\FXNote{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmenoteprefix: #1}}
\def\fixme@note@final#1{%
  \iffixme@silent\else\FXNote{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmenoteprefix: #1}}

%    \end{macrocode}
% \begin{macro}{\fixmewarningprefix}
%   \begin{macro}{\fixmewarningindexname}
%     \begin{macro}{\fixme@warning@draft}
%       \begin{macro}{\fixme@warning@final}
%         Here are the warnings notes:
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fixmewarningprefix{}
\newcommand*\fixmewarningindexname{}
\def\fixme@warning@draft#1{%
  \fixme@text{\fixmewarningprefix}{#1}%
  \iffixme@index\FXIndex{\fixmewarningindexname\thefixmewarningcount: #1}\fi%
  \iffixme@silent\else\FXWarning{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmewarningprefix: #1}}
\def\fixme@warning@final#1{%
  \iffixme@silent\else\FXWarning{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmewarningprefix: #1}}

%    \end{macrocode}
% \begin{macro}{\fixmeerrorprefix}
%   \begin{macro}{\fixmeerrorindexname}
%     \begin{macro}{\fixme@error@draft}
%       \begin{macro}{\fixme@error@final}
%         Here are the errors notes:
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fixmeerrorprefix{}
\newcommand*\fixmeerrorindexname{}
\def\fixme@error@draft#1{%
  \fixme@text{\fixmeerrorprefix}{#1}%
  \iffixme@index\FXIndex{\fixmeerrorindexname\thefixmeerrorcount: #1}\fi%
  \iffixme@silent\else\FXError{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmeerrorprefix: #1}}
\def\fixme@error@final#1{%
  \iffixme@silent\else\FXError{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmeerrorprefix: #1}}

%    \end{macrocode}
% \begin{macro}{\fixmefatalindexname}
%   \begin{macro}{\fixme@fatal@draft}
%     \begin{macro}{\fixme@fatal@final}
%       And here are the fatal ones:
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fixmefatalindexname{}
\def\fixme@fatal@draft#1{%
  \iffixme@inline\FiXmeInline{#1}\fi%
  \iffixme@margin\FiXmeMargin{#1}\fi%
  \iffixme@marginclue\FXMarginClue{\fixmefatalprefix}\fi%
  \iffixme@footnote\FiXmeFootnote{#1}\fi%
  \iffixme@user\FiXmeUser{#1}\fi%
  \iffixme@index\FiXmeIndex{%
    \fixmefatalindexname\thefixmefatalcount: #1}\fi%
  \iffixme@silent\else\FXFatal{#1}\fi%
  \addcontentsline{lox}{fixme}{\protect\fixmefatalprefix: #1}}
\def\fixme@fatal@final#1{%
  \PackageError{FiXme}{`#1' fixme left in final version}{%
    You are processing your document in final mode,\MessageBreak
    but you still have some critical FiXme's left behind.\MessageBreak
    Type X to quit, fix your document, and rerun LaTeX.}}

%    \end{macrocode}
% \begin{macro}{\@fixme}
%   \begin{macro}{\fxnote}
%     \begin{macro}{\fxwarning}
%       \begin{macro}{\fxerror}
%         \begin{macro}{\fixme}
%           Here are the notes insertion macros. The different versions are
%           |\let| to the draft of final flavors defined above by the
%           \texttt{draft} or \texttt{final} options.
%         \end{macro}
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\def\@@fixme#1#2{%
  \stepcounter{fixmecount}%
  \stepcounter{fixme#1count}%
  \csname fixme@#1\endcsname{#2}}
\def\@fixme#1[#2]#3{%
  \bgroup%
  \fixme@inlinefalse%
  \fixme@marginfalse%
  \fixme@margincluefalse%
  \fixme@footnotefalse%
  \fixme@userfalse%
  \fixme@indexfalse%
  \@for\fixme@option:=#2\do{%
    \expandafter\ifx\csname fixme@\fixme@option true\endcsname\relax
      \PackageError{FiXme}{Unknown layout option `\fixme@option'}{%
	You have given an invalid option to \string\fixme, or an \string\fx %
	command.\MessageBreak
	Valid options are `inline', `margin', `marginclue', `footnote', %
	`user',\MessageBreak
	and `index'.\MessageBreak
	Type X to quit, fix your document, and rerun LaTeX.}%
      \else%
      \csname fixme@set\fixme@option\endcsname%
    \fi}%
  \@@fixme{#1}{#3}%
  \egroup}
\DeclareRobustCommand\fxnote{\@ifnextchar[%]
  {\@fixme{note}}{\@@fixme{note}}}
\DeclareRobustCommand\fxwarning{\@ifnextchar[%]
  {\@fixme{warning}}{\@@fixme{warning}}}
\DeclareRobustCommand\fxerror{\@ifnextchar[%]
  {\@fixme{error}}{\@@fixme{error}}}
\DeclareRobustCommand\fixme{\@ifnextchar[%]
  {\@fixme{fatal}}{\@@fixme{fatal}}}

%    \end{macrocode}
%
% \subsection{\fixme{} environments}
% The \fixme{} environments use the corresponding macro version to handle
% inline (and possibly index) layout, and to perform logging. In final mode,
% verbatim's \texttt{comment} environment is used to suppress output.
%    \begin{macrocode}
\newcommand\FXEnvBegin{\begin{quotation}}
\newcommand\FXEnvEnd{\end{quotation}}

\def\@fxenvbegin@draft#1#2{%
  \FXEnvBegin
  \edef\fixme@args{inline%
    \iffixme@index,index\fi%
    \iffixme@marginclue,marginclue\fi}%
  \csname#1\endcsname[\fixme@args]{#2}}
\def\@fxenvbegin@final#1#2{
  \edef\fixme@args{inline%
    \iffixme@index,index\fi%
    \iffixme@marginclue,marginclue\fi}%
  \csname#1\endcsname[\fixme@args]{#2}
  \comment
}

\def\@fxenvend@draft{\FXEnvEnd}
\def\@fxenvend@final{\endcomment}

\newenvironment{anfxnote}[1][]{%
  \@fxenvbegin{fxnote}{#1}}{%
  \@fxenvend}
\newenvironment{anfxwarning}[1][]{%
  \@fxenvbegin{fxwarning}{#1}}{%
  \@fxenvend}
\newenvironment{anfxerror}[1][]{%
  \@fxenvbegin{fxerror}{#1}}{%
  \@fxenvend}
\newenvironment{afixme}[1][]{%
  \@fxenvbegin{fixme}{#1}}{%
  \@fxenvend}

%    \end{macrocode}
%
% \subsection{Language processing}
% Options that control which language is selected:
%    \begin{macrocode}
\DeclareOption{english}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Note}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Warning}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Error}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Notes:!}
  \renewcommand*\fixmewarningindexname{**b@Warnings:!}
  \renewcommand*\fixmeerrorindexname{**c@Errors:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{List of Corrections}}
\DeclareOption{french}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Note}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Attention}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Erreur}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Notes:!}
  \renewcommand*\fixmewarningindexname{**b@Avertissements:!}
  \renewcommand*\fixmeerrorindexname{**c@Erreurs:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{Liste des Corrections}}
\DeclareOption{francais}{\ExecuteOptions{french}}
\DeclareOption{spanish}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Nota}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Aviso}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Error}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Notas:!}
  \renewcommand*\fixmewarningindexname{**b@Avisos:!}
  \renewcommand*\fixmeerrorindexname{**c@Errores:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{Lista de Correcciones}}
\DeclareOption{italian}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Nota}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Avviso}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Errore}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Note:!}
  \renewcommand*\fixmewarningindexname{**b@Avvisi:!}
  \renewcommand*\fixmeerrorindexname{**c@Errori:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{Corrigenda}}
\DeclareOption{german}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Anm}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Warnung}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Fehler}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Anmerkungen:!}
  \renewcommand*\fixmewarningindexname{**b@Warnungen:!}
  \renewcommand*\fixmeerrorindexname{**c@Fehler:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{Verzeichnis der Korrekturen}}
\DeclareOption{ngerman}{%
  \ExecuteOptions{german}}
\DeclareOption{danish}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Note}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Advarsel}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Fejl}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Noter:!}
  \renewcommand*\fixmewarningindexname{**b@Advarsler:!}
  \renewcommand*\fixmeerrorindexname{**c@Fejl:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{Rettelser}}
\DeclareOption{croatian}{%
  \renewcommand*\fixmenoteprefix{\fixmelogo\nobreakspace Poruka}
  \renewcommand*\fixmewarningprefix{\fixmelogo\nobreakspace Upozorenje}
  \renewcommand*\fixmeerrorprefix{\fixmelogo\nobreakspace Gre\v ska}
  \renewcommand*\fixmefatalprefix{\fixmelogo}
  \renewcommand*\fixmeindexname{\fixmelogo}
  \renewcommand*\fixmenoteindexname{**a@Poruke:!}
  \renewcommand*\fixmewarningindexname{**b@Upozorenja:!}
  \renewcommand*\fixmeerrorindexname{**c@Greske:!}
  \renewcommand*\fixmefatalindexname{}
  \renewcommand*{\listfixmename}{Popis korekcija}}

%    \end{macrocode}
%
% \subsection{Document status processing}
% \begin{macro}{\fixme@note}
%   \begin{macro}{\fixme@warning}
%     \begin{macro}{\fixme@error}
%       Here's where the draft or final version of the internal macros are
%       selected.
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\DeclareOption{final}{
  \let\fixme@note\fixme@note@final
  \let\fixme@warning\fixme@warning@final
  \let\fixme@error\fixme@error@final
  \let\fixme@fatal\fixme@fatal@final
  \let\@fxenvbegin\@fxenvbegin@final
  \let\@fxenvend\@fxenvend@final
  \let\listoffixmes\listoffixmes@final
  }

\DeclareOption{draft}{
  \@ifclassloaded{article}{
    \let\@listoffixmes@pretoc\@listoffixmes@pretoc@article
    \let\@listoffixmes@posttoc\@listoffixmes@posttoc@article}{
    \@ifclassloaded{report}{
      \let\@listoffixmes@pretoc\@listoffixmes@pretoc@report
      \let\@listoffixmes@posttoc\@listoffixmes@posttoc@report}{
      \@ifclassloaded{book}{
	\let\@listoffixmes@pretoc\@listoffixmes@pretoc@book
	\let\@listoffixmes@posttoc\@listoffixmes@posttoc@book}{
	\@ifclassloaded{scrartcl}{
	  \let\@listoffixmes@pretoc\@listoffixmes@pretoc@scrartcl
	  \let\@listoffixmes@posttoc\@listoffixmes@posttoc@scrartcl}{
	  \@ifclassloaded{scrreprt}{
	    \let\@listoffixmes@pretoc\@listoffixmes@pretoc@scrreprt
	    \let\@listoffixmes@posttoc\@listoffixmes@posttoc@scrreprt}{
	    \@ifclassloaded{scrbook}{
	      \let\@listoffixmes@pretoc\@listoffixmes@pretoc@scrbook
	      \let\@listoffixmes@posttoc\@listoffixmes@posttoc@scrbook}{
	      \@ifclassloaded{amsbook}{
		\let\listoffixmes@draft\listoffixmes@draft@ams}{
		\@ifclassloaded{amsart}{
		  \let\listoffixmes@draft\listoffixmes@draft@ams}{
		  %% Use the article layout by default.
		  \let\@listoffixmes@pretoc\@listoffixmes@pretoc@article
		  \let\@listoffixmes@posttoc\@listoffixmes@posttoc@article}
	      }
	    }
	  }
	}
      }
    }
  }
  \let\fixme@note\fixme@note@draft
  \let\fixme@warning\fixme@warning@draft
  \let\fixme@error\fixme@error@draft
  \let\fixme@fatal\fixme@fatal@draft
  \let\@fxenvbegin\@fxenvbegin@draft
  \let\@fxenvend\@fxenvend@draft
  \let\listoffixmes\listoffixmes@draft
}

%    \end{macrocode}
% Put us in \texttt{english} and \texttt{final} mode, and enable the marginal
% notes. Note that as documented, marginal notes are incompatible with the ACM
% SIG classes. Initially, I thought I would detect these classes and issue
% an error if marginal layout (or clue) is active. However, I changed my mind,
% because nothing prevents somebody to write a new class on top of these ones
% and authorize |\marginpar| back again. Normally these classes issue an error
% if |\marginpar| is used. However, the 2.3 / June 2007 versions are buggy and
% the error actually triggers a stack overflow in \LaTeX\ldots Patch on its
% way. Oh boy, these classes are a mess.
%    \begin{macrocode}
\ExecuteOptions{english,final,margin,nosilent}
\ProcessOptions*

%    \end{macrocode}
% Finally, ensure backward compatibility for |\fixme| with |\FiXmeUser|, and
% output a summary giving the number of fixme notes at the end of the
% compilation:
%    \begin{macrocode}
\AtBeginDocument{%
  \ifx\FiXmeUser\empty
    \renewcommand\FiXmeUser[1]{\FXUser{\fixmefatalprefix}{#1}}
  \fi}

\AtEndDocument{%
  \GenericWarning{%
    (FiXme)\@spaces\@spaces\@spaces\@spaces
  }{%
    Package FiXme Summary: Number of notes: \thefixmenotecount,\MessageBreak%
    Number of warnings: \thefixmewarningcount,\MessageBreak%
    Number of errors: \thefixmeerrorcount,\MessageBreak%
    Number of fatal errors: \thefixmefatalcount,\MessageBreak%
    Total: \thefixmecount\@gobble%
  }}
%    \end{macrocode}
%
% ^^A \PrintChanges
% ^^A \PrintIndex
% \Finale
%
% ^^A fixme.dtx ends here.
