# -*- mode: Perl -*-
# /=====================================================================\ #
# |  tabulary                                                           | #
# | 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;

RequirePackage('array');

# \tabularx{Dimension}[]{}
DefMacro('\tabulary{}[]{}',
  '\@tabular@bindings{#3}[vattach=#2,width=#1]\@@tabulary{#1}[#2]{#3}\@start@alignment', locked => 1);
DefMacro('\endtabulary',
  '\@finish@alignment\@end@tabulary', locked => 1);
DefPrimitive('\@end@tabulary', sub { $_[0]->egroup; });
DefConstructor('\@@tabulary{Dimension}[] Undigested DigestedBody',
  '#4',
  reversion    => '\begin{tabulary}{#1}[#2]{#3}#4\end{tabulary}',
  beforeDigest => sub { $_[0]->bgroup; },
  mode         => 'text');

# Like l,c,r,j, but set like p w/o explicit width...
DefColumnType('L', sub {
    $LaTeXML::BUILD_TEMPLATE->addColumn(before => Tokens(T_CS('\vtop'), T_BEGIN),
      after => Tokens(T_END),
      align => 'left'); return; });
DefColumnType('C', sub {
    $LaTeXML::BUILD_TEMPLATE->addColumn(before => Tokens(T_CS('\vtop'), T_BEGIN),
      after => Tokens(T_END),
      align => 'center'); return; });
DefColumnType('R', sub {
    $LaTeXML::BUILD_TEMPLATE->addColumn(before => Tokens(T_CS('\vtop'), T_BEGIN),
      after => Tokens(T_END),
      align => 'right'); return; });
DefColumnType('J', sub {
    $LaTeXML::BUILD_TEMPLATE->addColumn(before => Tokens(T_CS('\vtop'), T_BEGIN),
      after => Tokens(T_END),
      align => 'justify'); return; });

# stub in for macros that try to redefine it.
DefMacro('\TY@tabular', '\relax');

1;
