diff --git a/lib/LaTeXML/Package/amscd.sty.ltxml b/lib/LaTeXML/Package/amscd.sty.ltxml index 4f8bb8038..cdb47ed66 100644 --- a/lib/LaTeXML/Package/amscd.sty.ltxml +++ b/lib/LaTeXML/Package/amscd.sty.ltxml @@ -43,22 +43,24 @@ DefMacro('\cd@ Token', sub { my ($gullet, $token) = @_; (T_CS('@' . ToString($token))); }); +# Horizontal connectors DefMacroI(T_CS('@>'), 'Until:> Until:>', - '\lx@hidden@align\cd@stack{>}{\rightarrowfill@}{#1}{#2}\lx@hidden@align'); + '\lx@hidden@align\lx@amscd@stack{>}{\lx@amscd@rightarrow}{#1}{#2}\lx@hidden@align'); DefMacroI(T_CS('@)'), 'Until:) Until:)', - '\lx@hidden@align\cd@stack{)}{\rightarrowfill@}{#1}{#2}\lx@hidden@align'); + '\lx@hidden@align\lx@amscd@stack{)}{\lx@amscd@rightarrow}{#1}{#2}\lx@hidden@align'); DefMacroI(T_CS('@<'), 'Until:< Until:<', - '\lx@hidden@align\cd@stack{<}{\leftarrowfill@}{#1}{#2}\lx@hidden@align'); + '\lx@hidden@align\lx@amscd@stack{<}{\lx@amscd@leftarrow}{#1}{#2}\lx@hidden@align'); DefMacroI(T_CS('@('), 'Until:( Until:(', - '\lx@hidden@align\cd@stack{(}{\leftarrowfill@}{#1}{#2}\lx@hidden@align'); + '\lx@hidden@align\lx@amscd@stack{(}{\lx@amscd@leftarrow}{#1}{#2}\lx@hidden@align'); +DefMacroI(T_CS('@='), undef, + '\lx@hidden@align\lx@amscd@equals\lx@hidden@align'); +# Vertical connectors DefMacroI(T_CS('@A'), 'Until:A Until:A', - '\cd@adjacent{A}{\Big\uparrow}{#1}{#2}\lx@hidden@align\lx@hidden@align'); + '\lx@amscd@adjacent{A}{\Big\uparrow}{#1}{#2}\lx@hidden@align\lx@hidden@align'); DefMacroI(T_CS('@V'), 'Until:V Until:V', - '\cd@adjacent{V}{\Big\downarrow}{#1}{#2}\lx@hidden@align\lx@hidden@align'); + '\lx@amscd@adjacent{V}{\Big\downarrow}{#1}{#2}\lx@hidden@align\lx@hidden@align'); -DefMacroI(T_CS('@='), undef, - '\lx@hidden@align\@cd@equals@\lx@hidden@align'); DefMacroI(T_CS('@|'), undef, '\Big\Vert\lx@hidden@align\lx@hidden@align'); DefMacroI(T_CS('@\vert'), undef, @@ -66,15 +68,9 @@ DefMacroI(T_CS('@\vert'), undef, DefMacroI(T_CS('@.'), undef, '\lx@hidden@align\lx@hidden@align'); -# Horizontal -DefMath('\@cd@equals@', "=", role => 'ARROW', stretchy => 'true', reversion => '@='); -# Vertical -DefMath('\@cd@bar@', "|", role => 'ARROW', font => { size => 'Big' }, reversion => '@|'); -DefMath('\@cd@vert@', "\x{2225}", role => 'ARROW', font => { size => 'Big' }, reversion => '@\vert'); - DefRegister('\minaw@' => Dimension('11.111pt')); -DefConstructor('\cd@stack Undigested {} ScriptStyle ScriptStyle', sub { +DefConstructor('\lx@amscd@stack Undigested {} ScriptStyle ScriptStyle', sub { my ($document, $reversion, $op, $over, $under, %props) = @_; my $scriptpos = $props{scriptpos}; if (!IsEmpty($under)) { @@ -101,22 +97,38 @@ DefConstructor('\cd@stack Undigested {} ScriptStyle ScriptStyle', sub { properties => { scriptpos => sub { "mid" . $_[0]->getScriptLevel; } }, reversion => '@#1{#3}#1{#4}#1'); -# Temporary... -# Later deal with vertically centering the side things, parser issues... - -DefConstructor('\cd@adjacent Undigested {} ScriptStyle ScriptStyle', sub { +DefConstructor('\lx@amscd@adjacent Undigested {} ScriptStyle ScriptStyle', sub { my ($document, $reversion, $op, $left, $right, %props) = @_; + # Make the left & right parts width=0, so they don't affect centering $document->openElement('ltx:XMWrap', role => 'ARROW'); # Role? - $document->insertElement('ltx:XMArg', $left) unless IsEmpty($left); + $document->insertElement('ltx:XMArg', $left, width => Dimension(0)) unless IsEmpty($left); $document->insertElement('ltx:XMArg', $op); - $document->insertElement('ltx:XMArg', $right) unless IsEmpty($right); + $document->insertElement('ltx:XMArg', $right, width => Dimension(0)) unless IsEmpty($right); $document->closeElement('ltx:XMWrap'); }, reversion => '@#1{#3}#1{#4}#1'); -# This isn't really having the desired effect when transformed to MathML and -# displayed in Firefox.... have I got it right; has Firefox??? -DefMath('\leftarrowfill@', "\x{2190}", role => 'ARROW', stretchy => 'true'); -DefMath('\rightarrowfill@', "\x{2192}", role => 'ARROW', stretchy => 'true'); +# These, in case used... +DefMacro('\leftarrowfill@ {}', '\lx@amscd@leftarrow'); +DefMacro('\rightarrowfill@ {}', '\lx@amscd@rightarrow'); +DefMacro('\leftrightarrowfill@ {}', '\lx@amscd@leftrightarrow'); + +# These are stretchy, widenned version; should be \minCDarrowsidth or \minaw@ wide +DefPrimitive('\lx@amscd@leftarrow', sub { + Box("\x{2190}", undef, undef, '\leftarrow', + role => 'ARROW', stretchy => 'true', meaning => 'leftarrow', + class=>'ltx_horizontally_stretchy', width => Dimension('30pt')); }); +DefPrimitive('\lx@amscd@rightarrow', sub { + Box("\x{2192}", undef, undef, '\rightarrow', + role => 'ARROW', stretchy => 'true', meaning => 'rightarrow', + class=>'ltx_horizontally_stretchy', width => Dimension('30pt')); }); +DefPrimitive('\lx@amscd@leftrightarrow', sub { + Box("\x{2194}", undef, undef, '\leftrightarrow', + role => 'ARROW', stretchy => 'true', meaning => 'leftrightarrow', + class=>'ltx_horizontally_stretchy', width => Dimension('30pt')); }); +DefPrimitive('\lx@amscd@equals', sub { + Box("=", undef, undef, T_OTHER('='), + role => 'ARROW', stretchy => 'true', meaning => 'equals', + class=>'ltx_horizontally_stretchy', width => Dimension('30pt')); }); DefRegister('\minCDarrowwidth' => Dimension('2.5pc')); diff --git a/lib/LaTeXML/Post/MathML.pm b/lib/LaTeXML/Post/MathML.pm index a147757a1..3bd8784b6 100644 --- a/lib/LaTeXML/Post/MathML.pm +++ b/lib/LaTeXML/Post/MathML.pm @@ -535,7 +535,15 @@ sub pmml_maybe_resize { my $depth = $node->getAttribute('depth') || ($parent && $parent->getAttribute('depth')); my $xoff = $node->getAttribute('xoffset') || ($parent && $parent->getAttribute('xoffset')); my $yoff = $node->getAttribute('yoffset') || ($parent && $parent->getAttribute('yoffset')); - if ($width || $height || $depth || $xoff || $yoff) { + my $role = $node->getAttribute('role') || ($parent && $parent->getAttribute('role')); + my $class = $node->getAttribute('class') || ($parent && $parent->getAttribute('class')); + + # First, special case hack for stretchy arrows, with specified width + # Stretchiness (currently) only has effect within munder/mover!!!!! + if ($width && (($role || '') eq 'ARROW') + && (($class||'') =~ /\bltx_horizontally_stretchy\b/)) { # SPECIAL CASE HACK + $result = ['m:mover', {}, $result, ['m:mspace', { width => $width }]]; } + elsif ($width || $height || $depth || $xoff || $yoff) { if ($$result[0] eq 'm:mpadded') { } elsif ($$result[0] eq 'm:mrow') { $$result[0] = 'm:mpadded'; } diff --git a/t/ams/cd.pdf b/t/ams/cd.pdf index 1328836a2..c05aeeb36 100644 Binary files a/t/ams/cd.pdf and b/t/ams/cd.pdf differ diff --git a/t/ams/cd.tex b/t/ams/cd.tex index 03fde518b..8929ae928 100644 --- a/t/ams/cd.tex +++ b/t/ams/cd.tex @@ -16,9 +16,9 @@ \end{equation} \begin{equation} \begin{CD} -\cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>> \cf(\mathcal{L})\\ -@VVV @AAA @AAA @VVV\\ -\add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>> \non(\mathcal{L}) +\cov(\mathcal{L}) @>i>j> \non(\mathcal{K}) @)i)) \cf(\mathcal{K}) @>>j> \cf(\mathcal{L})\\ +@VVV @| @\vert @AAA\\ +\add(\mathcal{L}) @<<< \add(\mathcal{K}) @((( \cov(\mathcal{K}) @<<< \non(\mathcal{L}) \end{CD} \end{equation} \end{document} diff --git a/t/ams/cd.xml b/t/ams/cd.xml index 748a48b82..1d75bfd6a 100644 --- a/t/ams/cd.xml +++ b/t/ams/cd.xml @@ -12,7 +12,7 @@ (1) 1 - + @@ -39,7 +39,7 @@ - + j @@ -56,7 +56,7 @@ - + End P @@ -85,7 +85,7 @@ - = + = @@ -116,7 +116,7 @@ (2) 2 - + @@ -142,7 +142,15 @@ - + + + + + + i + + j + @@ -161,7 +169,11 @@ - + + + + i + @@ -180,7 +192,11 @@ - + + + + j + @@ -205,15 +221,15 @@ - + - + - + @@ -236,7 +252,7 @@ - + @@ -255,7 +271,7 @@ - + @@ -274,7 +290,7 @@ - +