# -*- CPERL -*-
# /=====================================================================\ #
# |  article                                                            | #
# | 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=/ #
use strict;
use LaTeXML::Package;
package LaTeXML::Package::Pool;

#**********************************************************************
# Option handling
foreach my $option (qw(10pt 11pt 12pt 
		       letterpaper legalpaper executivepaper a4paper a5paper b5paper
		       landscape
		       final draft
		       oneside twoside
		       openright openany
		       onecolumn twocolumn 
		       notitlepage titlepage
		       openbib
		       leqno fleqn)){
  DeclareOption($option,undef); }
ProcessOptions();

#**********************************************************************
# Document structure.
RelaxNGSchema("LaTeXML");


DefMacro('\@ptsize','0');	# should depend on options...
RawTeX(<<'EOTeX');
\newif\if@restonecol
\newif\if@titlepage
\@titlepagefalse
EOTeX

#**********************************************************************
# The core sectioning commands are defined in LaTeX.pm
# but the counter setup, etc, depends on article
#Let('\thedocument@ID','\@empty');
NewCounter('part',         'document',     idprefix=>'Pt', nested=>['section']);
NewCounter('section',      'document',     idprefix=>'S',  nested=>['subsection']);
NewCounter('subsection',   'section',      idprefix=>'SS', nested=>['subsubsection']);
NewCounter('subsubsection','subsection',   idprefix=>'SSS',nested=>['paragraph']);
NewCounter('paragraph',    'subsubsection',idprefix=>'P',  nested=>['subparagraph']);
NewCounter('subparagraph', 'paragraph',    idprefix=>'SP', nested=>['equation','figure','table']);

DefMacro('\thepart',         '\Roman{part}');
DefMacro('\thesection',      '\arabic{section}');
DefMacro('\thesubsection',   '\thesection.\arabic{subsection}');
DefMacro('\thesubsubsection','\thesubsection.\arabic{subsubsection}');
DefMacro('\theparagraph',    '');
DefMacro('\thesubparagraph', '');

NewCounter('equation', 'document', idprefix=>'E', idwithin=>'section');
NewCounter('figure',   'document', idprefix=>'F', idwithin=>'section');
NewCounter('table',    'document', idprefix=>'T', idwithin=>'section');

DefMacro('\theequation', '\arabic{equation}');
DefMacro('\thefigure',   '\arabic{figure}');
DefMacro('\thetable',    '\arabic{table}');

NewCounter('@itemizei',   'document',   idprefix=>'I');
NewCounter('@itemizeii',  '@itemizei',  idprefix=>'I');
NewCounter('@itemizeiii', '@itemizeii', idprefix=>'I');
NewCounter('@itemizeiv',  '@itemizeiii',idprefix=>'I');
NewCounter('@itemizev',   '@itemizeiv', idprefix=>'I');
NewCounter('@itemizevi',  '@itemizev',  idprefix=>'I');

NewCounter('enumi',  '@itemizei',   idprefix=>'i');
NewCounter('enumii', '@itemizeii',  idprefix=>'i');
NewCounter('enumiii','@itemizeiii', idprefix=>'i');
NewCounter('enumiv', '@itemizeiv',  idprefix=>'i');
# A couple of more levels, since we use these for ID's!
NewCounter('enumv',  '@itemizev',   idprefix=>'i');
NewCounter('enumvi', '@itemizevi',  idprefix=>'i');

DefMacro('\theenumi',           '\arabic{enumi}');
DefMacro('\theenumii',          '\alph{enumii}');
DefMacro('\theenumiii',         '\roman{enumiii}');
DefMacro('\theenumiv',          '\Alph{enumiv}');

Tag('ltx:appendix',autoClose=>1);
# Actually we should be using section counter
AssignValue(counter_for_appendix=>'section');
DefMacro('\appendix@section', '\@startsection{appendix}{}{}{}{}{}');
DefPrimitive('\appendix',sub{
  NewCounter('section', 'document', idprefix=>'A',nested=>['subsection']);
  DefMacro('\thesection', '\Alph{section}',scope=>'global');
  Let(T_CS('\section'),T_CS('\appendix@section'),'global');
  Let(T_CS('\appendix'),T_CS('\relax'),'global');
 });

#**********************************************************************
1;
