# -*- mode: Perl -*-
# /=====================================================================\ #
# |  jheppub                                                            | #
# | 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.     | #
# |---------------------------------------------------------------------| #
# | Thanks to the arXMLiv group for initial implementation              | #
# |    http://arxmliv.kwarc.info/                                       | #
# | Released to the Public Domain                                       | #
# |---------------------------------------------------------------------| #
# | 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;

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RequirePackage('hyperref');
RequirePackage('color');
RequirePackage('natbib');
RequirePackage('amsmath');
RequirePackage('amssymb');
RequirePackage('epsfig');
RequirePackage('graphicx');
RequirePackage('inst_support');
# \author[]{}
DefMacro('\author[]{}',
  '\ifx.#1.\else\@institutemark{#1}\fi'
    . '\def\@author{#2}\lx@author{#2}', locked => 1);

DefConstructor('\affiliation[]{}',
  "<ltx:note role='institutetext' mark='#1'>#2</ltx:note>",
  bounded => 1, beforeDigest => sub { AssignValue(inPreamble => 0); });

# \note{} appears inside author?
Let('\note', '\footnote');

DefConstructor('\@@@email{}', "^ <ltx:contact role='email'>#1</ltx:contact>");
DefMacro('\emailAdd Semiverbatim', '\@add@to@frontmatter{ltx:creator}{\@@@email{#1}}');

DefMacro('\keywordname', '\textbf{Keywords}');
DefMacro('\keywords{}',  '\@add@frontmatter{ltx:keywords}[name={\keywordname}]{#1}');

DefMacro('\arxivnumber{}',        '\@add@frontmatter{ltx:note}[role=arxiv]{#1}');
DefMacro('\preprint{}',           '\@add@frontmatter{ltx:note}[role=preprint]{#1}');
DefMacro('\proceeding{}',         '\@add@frontmatter{ltx:note}[role=proceeding]{#1}');
DefMacro('\dedicated{}',          '\@add@frontmatter{ltx:note}[role=dedication]{#1}');
DefMacro('\collaboration{}{}',    '\@add@to@frontmatter{ltx:creator}{\@@@collaborator{#2}}');
DefMacro('\collaborationImg[]{}', '');                                                          # ?

DefMacro('\acknowledgmentsname', 'Acknowledgements');
DefConstructor('\acknowledgments', "<ltx:acknowledgements name='#name'>",
  properties => sub { (name => Digest(T_CS('\acknowledgmentsname'))); });
DefConstructor('\endacknowledgments', "</ltx:acknowledgements>");
Tag("ltx:acknowledgements", autoClose => 1);

DefConditional('\ifaffil',         undef);
DefConditional('\ifnotoc',         undef);
DefConditional('\ifemailadd',      undef);
DefConditional('\iftoccontinuous', undef);

# explicitly empty
DefMacro('\@subheader',        '\@empty');
DefMacro('\@keywords',         '\@empty');
DefMacro('\@abstract',         '\@empty');
DefMacro('\@xtum',             '\@empty');
DefMacro('\@dedicated',        '\@empty');
DefMacro('\@arxivnumber',      '\@empty');
DefMacro('\@collaboration',    '\@empty');
DefMacro('\@collaborationImg', '\@empty');
DefMacro('\@proceeding',       '\@empty');
DefMacro('\@preprint',         '\@empty');

# spacing macros
DefMacro('\afterLogoSpace',             '\smallskip');
DefMacro('\afterSubheaderSpace',        '\vskip3pt plus 2pt minus 1pt');
DefMacro('\afterProceedingsSpace',      '\vskip21pt plus0.4fil minus15pt');
DefMacro('\afterTitleSpace',            '\vskip23pt plus0.06fil minus13pt');
DefMacro('\afterRuleSpace',             '\vskip23pt plus0.06fil minus13pt');
DefMacro('\afterCollaborationSpace',    '\vskip3pt plus 2pt minus 1pt');
DefMacro('\afterCollaborationImgSpace', '\vskip3pt plus 2pt minus 1pt');
DefMacro('\afterAuthorSpace',           '\vskip5pt plus4pt minus4pt');
DefMacro('\afterAffiliationSpace',      '\vskip3pt plus3pt');
DefMacro('\afterEmailSpace',            '\vskip16pt plus9pt minus10pt\filbreak');
DefMacro('\afterXtumSpace',             '\par\bigskip');
DefMacro('\afterAbstractSpace',         '\vskip16pt plus9pt minus13pt');
DefMacro('\afterKeywordsSpace',         '\vskip16pt plus9pt minus13pt');
DefMacro('\afterArxivSpace',            '\vskip3pt plus0.01fil minus10pt');
DefMacro('\afterDedicatedSpace',        '\vskip0pt plus0.01fil');
DefMacro('\afterTocSpace',              '\bigskip\medskip');
DefMacro('\afterTocRuleSpace',          '\bigskip\bigskip');

# no effect in latexml
DefMacro('\beforetochook', '');
DefMacro('\notoc',         '');
DefMacro('\compress',      '');

# misc
DefMacro('\correctionref{}{}{}', '\gdef\@xtum{\xtumfont{#1} \href{#2}{#3}}}');
DefMacro('\jname',               'JHEP');
DefMacro('\subheader{}',         '');
DefMacro('\xtumfont{}',          '\textsc{#1}');
Let('\oldthebibliography',    '\thebibliography');
Let('\endoldthebibliography', '\endthebibliography');

#======================================================================
1;