# -*- mode: Perl -*-
# /=====================================================================\ #
# |  theorem                                                            | #
# | Implementation for LaTeXML                                          | #
# |=====================================================================| #
# | Part of LaTeXML:                                                    | #
# |  Public domain software, produced as part of work done by the       | #
# |  United States Government & not subject to copyright in the US.     | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     | #
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;

#**********************************************************************
# \newtheorem in LaTeX.pool
# This is close enough to amsthm to just use it.
RequirePackage('amsthm');
# However, theorem.sty's styles do NOT record the headfont!
setSavableTheoremParameters(qw(
    \thm@bodyfont \thm@headpunct
    \thm@styling \thm@headstyling thm@swap));

# And headpunct defaults to none.
DefRegister('\thm@headpunct' => Tokens());

DefMacro('\FMithmInfo', '');

DefMacro('\theoremheaderfont{}', sub {
    AssignValue('\thm@headfont' => $_[1]);
    AssignValue('\thm@notefont' => $_[1]); });

# \th@plain defined in LaTeX.pool, but amsthm redefines to add .
DefPrimitive('\lx@theorem@newtheoremstyle{}{}{}{}', sub {
    my ($stomach, $name, $bodyfont, $headstyle, $swap) = @_;
    $name = ToString($name);
    saveTheoremStyle($name,
      '\thm@bodyfont'    => $bodyfont,
      '\thm@headstyling' => $headstyle,
      'thm@swap'         => ToString($swap) eq 'S',
    );
    DefMacroI(T_CS('\th@' . $name), undef, sub { useTheoremStyle($name); });
    return; });

RawTeX(<<'EoTeX');
\lx@theorem@newtheoremstyle{plain}{\itshape}{\lx@makerunin}{N}
\lx@theorem@newtheoremstyle{break}{\slshape}{}{N}
\lx@theorem@newtheoremstyle{change}{\slshape}{\lx@makerunin}{S}
\lx@theorem@newtheoremstyle{margin}{\slshape}{\lx@makerunin\lx@makeoutdent}{S}
\lx@theorem@newtheoremstyle{marginbreak}{\slshape}{\lx@makeoutdent}{S}
\lx@theorem@newtheoremstyle{changebreak}{\slshape}{}{S}
% Redefine so we get correct parameters recorded
\lx@theorem@newtheoremstyle{definition}{}{\lx@makerunin}{\normalfont}%{}{\bfseries}{.}{}{}
\lx@theorem@newtheoremstyle{remark}{}{}{\normalfont}%{}{\itshape}{.}{}{}
\th@plain
EoTeX
#**********************************************************************
1;
