Skip to content

Commit 3bc3212

Browse files
committed
fbox: add padding only to framed boxes generated by \fbox, \framebox
1 parent 9f3fa9f commit 3bc3212

8 files changed

Lines changed: 25 additions & 13 deletions

File tree

lib/LaTeXML/Package/amsmath.sty.ltxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,12 +896,14 @@ DefConstructor('\boxed@math{}',
896896
alias => '\boxed');
897897

898898
DefConstructor('\boxed@text{}',
899-
"<ltx:Math mode='display' framed='rectangle'>"
899+
"<ltx:Math mode='display' framed='rectangle' framecolor='#framecolor' cssstyle='#cssstyle'>"
900900
. "<ltx:XMath>"
901901
. "#1"
902902
. "</ltx:XMath>"
903903
. "</ltx:Math>",
904904
mode => 'math', bounded => 1,
905+
properties => sub {
906+
framedProperties(margin => '\fboxsep'); },
905907
beforeDigest => sub {
906908
Let("\\\\", '\lx@newline'); },
907909
alias => '\boxed');

lib/LaTeXML/Package/color.sty.ltxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ DefMacro('\colorbox[]{}{}', '\hbox{\ifx.#1.\pagecolor{#2}\else\pagecolor[#1]{#2}
106106

107107
#\fcolorbox{name}{text} or \fcolorbox[model]{spec}{text}
108108
DefConstructor('\fcolorbox[]{}{} Undigested',
109-
"<ltx:text framed='rectangle' framecolor='#framecolor'"
109+
"<ltx:text framed='rectangle' framecolor='#framecolor' cssstyle='#cssstyle'"
110110
. " _noautoclose='1'>#text</ltx:text>",
111111
mode => 'internal_vertical',
112+
properties => sub {
113+
framedProperties(margin => '\fboxsep'); },
112114
afterDigest => sub {
113115
my ($stomach, $whatsit) = @_;
114116
my ($model, $fspec, $bspec, $text) = $whatsit->getArgs;

lib/LaTeXML/Package/listings.sty.ltxml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ DefConstructor('\@@listings {}',
259259
afterDigest => sub { afterFloat($_[1]); });
260260

261261
DefConstructor('\@@listings@block {} {} {}',
262-
"<ltx:listing class='ltx_lstlisting' data='#data' datamimetype='#datamimetype' dataencoding='#dataencoding' dataname='#3'>#2</ltx:listing>",
262+
"<ltx:listing class='ltx_lstlisting' data='#data' datamimetype='#datamimetype' dataencoding='#dataencoding' dataname='#3' cssstyle='#cssstyle'>#2</ltx:listing>",
263263
mode => 'internal_vertical',
264264
afterDigest => sub {
265265
my ($stomach, $whatsit) = @_;
@@ -270,7 +270,11 @@ DefConstructor('\@@listings@block {} {} {}',
270270
$listings_data = encode('UTF-8', $listings_data);
271271
}
272272
my $data = encode_base64($listings_data, ''); # NO linebreaking!
273-
$whatsit->setProperties(data => $data, datamimetype => 'text/plain', dataencoding => 'base64'); });
273+
$whatsit->setProperties(data => $data, datamimetype => 'text/plain', dataencoding => 'base64');
274+
if ((my $framesep = LookupValue('LST@framesep'))) {
275+
$whatsit->setProperties(padtop => $framesep, padbottom => $framesep, padleft => $framesep, padright => $framesep);
276+
$whatsit->setProperties(cssstyle => 'padding:' . $framesep->toAttribute) if $framesep->ptValue != 3 ; }
277+
return; });
274278

275279
DefMacro('\lst@HRefStepCounter{}', '');
276280

lib/LaTeXML/Package/xcolor.sty.ltxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,11 @@ DefPrimitive('\rrshift Variable', sub {
876876

877877
#\fcolorbox{name}{text} or \fcolorbox[model]{spec}{text}
878878
DefConstructor('\fcolorbox[]{}{} Undigested',
879-
"<ltx:text framed='rectangle' framecolor='#framecolor'"
879+
"<ltx:text framed='rectangle' framecolor='#framecolor' cssstyle='#cssstyle'"
880880
. " _noautoclose='1'>#text</ltx:text>",
881881
enterHorizontal => 1, mode => 'internal_vertical', sizer => '#text',
882+
properties => sub {
883+
framedProperties(margin => '\fboxsep'); },
882884
afterDigest => sub {
883885
my ($stomach, $whatsit) = @_;
884886
my ($model, $fspec, $bspec, $text) = $whatsit->getArgs;

lib/LaTeXML/resources/CSS/LaTeXML.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ dl.ltx_description dl.ltx_description dd { margin-left:3em; }
317317
margin: 1ex 3em 1ex 0em;
318318
overflow-x:auto;
319319
text-align: left; }
320+
.ltx_lstlisting.ltx_listing {
321+
padding: 3pt; }
320322
.ltx_float .ltx_listing {
321323
margin: 0; }
322324
.ltx_listingline { white-space:nowrap; min-height:1em; }

t/graphics/colors.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ vs. <text color="#E6E6E6">Light</text></p>
105105
<p>vs. <text backgroundcolor="#808080" color="#E6E6E6">Light within Gray</text></p>
106106
</para>
107107
<para xml:id="S5.p3">
108-
<p><text backgroundcolor="#FF0000" color="#00FF00" framecolor="#0000FF" framed="rectangle">Green in Red surrounded by Blue</text></p>
108+
<p><text backgroundcolor="#FF0000" color="#00FF00" cssstyle="padding:3.0pt" framecolor="#0000FF" framed="rectangle">Green in Red surrounded by Blue</text></p>
109109
</para>
110110
<para xml:id="S5.p4">
111-
<p><text backgroundcolor="#00FFFF" color="#FFFF00" framecolor="#FF00FF" framed="rectangle">Yellow in Cyan surrounded by Magenta</text></p>
111+
<p><text backgroundcolor="#00FFFF" color="#FFFF00" cssstyle="padding:3.0pt" framecolor="#FF00FF" framed="rectangle">Yellow in Cyan surrounded by Magenta</text></p>
112112
</para>
113113
</section>
114114
<section inlist="toc" xml:id="S6">
@@ -152,9 +152,9 @@ vs. <text color="#E6E6E6">Light</text></p>
152152
<XMath>
153153
<XMApp>
154154
<XMTok meaning="plus" role="ADDOP">+</XMTok>
155-
<XMText backgroundcolor="#0000FF" framecolor="#00FF00" framed="rectangle"><text color="#FF0000">R</text></XMText>
156-
<XMText backgroundcolor="#FF0000" framecolor="#0000FF" framed="rectangle"><text color="#00FF00">G</text></XMText>
157-
<XMText backgroundcolor="#00FF00" framecolor="#FF0000" framed="rectangle"><text color="#0000FF">B</text></XMText>
155+
<XMText backgroundcolor="#0000FF" cssstyle="padding:3.0pt" framecolor="#00FF00" framed="rectangle"><text color="#FF0000">R</text></XMText>
156+
<XMText backgroundcolor="#FF0000" cssstyle="padding:3.0pt" framecolor="#0000FF" framed="rectangle"><text color="#00FF00">G</text></XMText>
157+
<XMText backgroundcolor="#00FF00" cssstyle="padding:3.0pt" framecolor="#FF0000" framed="rectangle"><text color="#0000FF">B</text></XMText>
158158
</XMApp>
159159
</XMath>
160160
</Math>

t/graphics/xcolors.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ No blend: <text width="20.0pt"><rule color="#FF0000" height="6.5pt" width="20.0p
221221
<p>vs. <text backgroundcolor="#808080" color="#E6E6E6">Light within Gray</text></p>
222222
</para>
223223
<para xml:id="S7.p3">
224-
<p><text backgroundcolor="#FF0000" color="#00FF00" framecolor="#0000FF" framed="rectangle">Green in Red surrounded by Blue</text></p>
224+
<p><text backgroundcolor="#FF0000" color="#00FF00" cssstyle="padding:3.0pt" framecolor="#0000FF" framed="rectangle">Green in Red surrounded by Blue</text></p>
225225
</para>
226226
<para xml:id="S7.p4">
227-
<p><text backgroundcolor="#00FFFF" color="#FFFF00" framecolor="#FF00FF" framed="rectangle">Yellow in Cyan surrounded by Magenta</text></p>
227+
<p><text backgroundcolor="#00FFFF" color="#FFFF00" cssstyle="padding:3.0pt" framecolor="#FF00FF" framed="rectangle">Yellow in Cyan surrounded by Magenta</text></p>
228228
</para>
229229
<rule color="#FFFFFF" depth="4.3pt" framecolor="#FF8000" framed="rectangle" height="8.6pt" width="100.0pt"/>
230230
</section>

t/math/sampler.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ attributes <text font="typewriter">@mathvariant</text>, <text font="typewriter">
199199
<XMTok role="PUNCT" rpadding="20.0pt">,</XMTok>
200200
<XMTok color="#00FF00" font="italic" role="UNKNOWN" xml:id="S1.E4.m1.3">X</XMTok>
201201
<XMTok role="PUNCT" rpadding="20.0pt">,</XMTok>
202-
<XMText backgroundcolor="#FF0000" framecolor="#0000FF" framed="rectangle" xml:id="S1.E4.m1.4"><text color="#00FF00">X</text></XMText>
202+
<XMText backgroundcolor="#FF0000" cssstyle="padding:3.0pt" framecolor="#0000FF" framed="rectangle" xml:id="S1.E4.m1.4"><text color="#00FF00">X</text></XMText>
203203
</XMWrap>
204204
</XMDual>
205205
</XMath>

0 commit comments

Comments
 (0)