# -*- mode: Perl -*-
# /=====================================================================\ #
# | cancel | #
# | 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;
#======================================================================
# Ignore them all, for the moment.
foreach my $option (qw(samesize smaller Smaller makeroom overlap thicklines)) {
DeclareOption($option, undef); }
#======================================================================
# The really annoying thing with \CancelColor is to
# get the strike-through done in that color,
# but have the contents be "normal" color!
# \def\CancelColor{\black} ??
DefMacro('\CancelColor', '');
sub cancelColorProperties {
my %props = (innerfont => LookupValue('font'));
$STATE->getStomach->bgroup;
if (Digest(T_CS('\CancelColor'))) {
$props{cancelfont} = LookupValue('font');
$props{forcefont} = 'true'; }
$STATE->getStomach->egroup;
return %props; }
#======================================================================
# Basic macros
# \cancel{expression} Cancels with /
DefMacro('\cancel{}',
'\ifmmode\@@math@cancel{#1}\else\@@text@cancel{#1}\fi');
# \bcancel{expression} Cancels with \
DefMacro('\bcancel{}',
'\ifmmode\@@math@bcancel{#1}\else\@@text@bcancel{#1}\fi');
# \xcancel{expression} Cancels with X
DefMacro('\xcancel{}',
'\ifmmode\@@math@xcancel{#1}\else\@@text@xcancel{#1}\fi');
#======================================================================
# Math mode
DefConstructor('\@@math@cancel{}',
"<ltx:XMApp>"
. "<ltx:XMTok role='ENCLOSE' enclose='updiagonalstrike' meaning='cancel'"
. " _force_font='#forcefont' _font='#cancelfont'/>"
. "<ltx:XMWrap>#1</ltx:XMWrap>"
. "</ltx:XMApp>",
alias => '\cancel',
properties => \&cancelColorProperties);
DefConstructor('\@@math@bcancel{}',
"<ltx:XMApp>"
. "<ltx:XMTok role='ENCLOSE' enclose='downdiagonalstrike' meaning='cancel'"
. " _force_font='#forcefont' _font='#cancelfont'/>"
. "<ltx:XMWrap>#1</ltx:XMWrap>"
. "</ltx:XMApp>",
alias => '\bcancel',
properties => \&cancelColorProperties);
DefConstructor('\@@math@xcancel{}',
"<ltx:XMApp>"
. "<ltx:XMTok role='ENCLOSE' enclose='updiagonalstrike downdiagonalstrike' meaning='cancel'"
. " _force_font='#forcefont' _font='#cancelfont'/>"
. "<ltx:XMWrap>#1</ltx:XMWrap>"
. "</ltx:XMApp>",
alias => '\xcancel',
properties => \&cancelColorProperties);
# This only works in math mode
# \cancelto{value}{expression}
# Note that the slashthrough SHOULD be an arrow!!!
# Since enclose maps to MathML's menclose notation, which is open-ended,
# we can add a not-(yet)-standard updiagnonalarrow (as suggested by Frederic Wang)
DefConstructor('\cancelto{}{}',
"<ltx:XMApp>"
. "<ltx:XMTok role='SUPERSCRIPTOP'/>"
. "<ltx:XMApp>"
. "<ltx:XMTok role='ENCLOSE' enclose='updiagonalstrike updiagonalarrow' meaning='cancel'"
. " _force_font='#forcefont' _font='#cancelfont'/>"
. "<ltx:XMWrap>#2</ltx:XMWrap>"
. "</ltx:XMApp>"
. "<ltx:XMWrap>#1</ltx:XMWrap>"
. "</ltx:XMApp>",
properties => \&cancelColorProperties);
#======================================================================
# This works, except that
# there isn't any CSS to create the different types of cross throughs
DefConstructor('\@@text@cancel{}',
"<ltx:del class='downdiagonalstrike' _force_font='#forcefont' _font='#cancelfont'>"
. "<ltx:text _noautoclose='1' _force_font='#forcefont' _font='#innerfont'>"
. "#1"
. "</ltx:text>"
. "</ltx:del>",
alias => '\cancel',
properties => \&cancelColorProperties);
DefConstructor('\@@text@bcancel{}',
"<ltx:del class='updiagonalstrike' _force_font='#forcefont' _font='#cancelfont'>"
. "<ltx:text _noautoclose='1' _force_font='#forcefont' _font='#innerfont'>"
. "#1"
. "</ltx:text>"
. "</ltx:del>",
alias => '\bcancel',
properties => \&cancelColorProperties);
DefConstructor('\@@text@xcancel{}',
"<ltx:del class='downdiagonalstrike updiagonalstrike' _force_font='#forcefont' _font='#cancelfont'>"
. "<ltx:text _noautoclose='1' _force_font='#forcefont' _font='#innerfont'>"
. "#1"
. "</ltx:text>"
. "</ltx:del>",
alias => '\xcancel',
properties => \&cancelColorProperties);
ProcessOptions();
1;