Skip to content

Commit a17569c

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

8 files changed

Lines changed: 41 additions & 30 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: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@ DefConstructor('\@@listings {}',
258258
beforeDigest => sub { beforeFloat('lstlisting'); },
259259
afterDigest => sub { afterFloat($_[1]); });
260260

261+
our %frames = (none => undef, leftline => 'left', topline => 'top', bottomline => 'bottom',
262+
lines => 'topbottom', single => 'rectangle', shadowbox => 'rectangle');
263+
261264
DefConstructor('\@@listings@block {} {} {}',
262-
"<ltx:listing class='ltx_lstlisting' data='#data' datamimetype='#datamimetype' dataencoding='#dataencoding' dataname='#3'>#2</ltx:listing>",
265+
"<ltx:listing class='ltx_lstlisting' data='#data' datamimetype='#datamimetype' dataencoding='#dataencoding' dataname='#3' cssstyle='#cssstyle' framed='#framed' framecolor='#framecolor'>#2</ltx:listing>",
263266
mode => 'internal_vertical',
264267
afterDigest => sub {
265268
my ($stomach, $whatsit) = @_;
@@ -270,7 +273,19 @@ DefConstructor('\@@listings@block {} {} {}',
270273
$listings_data = encode('UTF-8', $listings_data);
271274
}
272275
my $data = encode_base64($listings_data, ''); # NO linebreaking!
273-
$whatsit->setProperties(data => $data, datamimetype => 'text/plain', dataencoding => 'base64'); });
276+
$whatsit->setProperties(data => $data, datamimetype => 'text/plain', dataencoding => 'base64');
277+
my $frame = ToString(LookupValue('LST@frame'));
278+
if ($frame ne 'none') {
279+
my $border = $frames{$frame};
280+
if (!defined $border) {
281+
$border = join(' ',
282+
$frame =~ m/t/i ? ('top') : (),
283+
$frame =~ m/b/i ? ('bottom') : (),
284+
$frame =~ m/l/i ? ('left') : (),
285+
$frame =~ m/r/i ? ('right') : ());
286+
}
287+
$whatsit->setProperties(framedProperties(frame => $border, margin => LookupValue('LST@framesep'))); }
288+
return; });
274289

275290
DefMacro('\lst@HRefStepCounter{}', '');
276291

@@ -498,8 +513,8 @@ sub lstSetClassStyle {
498513
$props{class} = $stylestring; } # add indirect to class.
499514
else {
500515
delete $$classes{$class}{class};
501-
$props{begin} = Tokens($style, T_BEGIN); # Otherwise, presumably TeX
502-
$props{end} = T_END; } }
516+
$props{begin} = Tokens($style, T_BEGIN); # Otherwise, presumably TeX
517+
$props{end} = T_END; } }
503518
if ($class =~ /^(\w+?)s?$/) {
504519
$props{cssclass} = $1; }
505520
map { $$classes{$class}{$_} = $props{$_} } keys %props;
@@ -920,17 +935,7 @@ DefKeyVal('LST', 'breakautoindent', '', 'true');
920935
# 4.11 Frames
921936
#======================================================================
922937
# Mosly ignorable, but some could be used
923-
DefKeyVal('LST', 'frame', ''); # none | leftline | topline | bottomline | lines | single | shadowbox
924-
our %frames = (none => undef, leftline => 'left', topline => 'top', bottomline => 'bottom',
925-
lines => 'topbottom', single => 'rectangle', shadowbox => 'rectangle');
926-
DefPrimitive('\lst@@frame Until:\end', sub {
927-
my $name = ToString(Digest($_[1]));
928-
AssignValue(LISTINGS_FRAME => $frames{$name});
929-
lstPushValueLocally(LISTINGS_PREAMBLE => T_CS('\lst@@@set@frame')); });
930-
931-
DefConstructor('\lst@@@set@frame', "^framed='#frame'",
932-
properties => {
933-
frame => sub { LookupValue('LISTINGS_INLINE') ? undef : LookupValue('LISTINGS_FRAME'); } });
938+
DefKeyVal('LST', 'frame', ''); # none | leftline | topline | bottomline | lines | single | shadowbox, see %frames
934939

935940
DefKeyVal('LST', 'framearound', ''); # t|f * 4
936941
DefKeyVal('LST', 'framesep', 'Dimension');

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;

t/alignment/listing.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ and with messed up braces <text class="ltx_lst_numbers_left ltx_lstlisting"><tex
374374
</tags>
375375
<title><tag close=" ">7</tag>Framing and such</title>
376376
<para xml:id="S7.p1">
377-
<listing backgroundcolor="#FF5EFF" class="ltx_lst_language_Pascal ltx_lst_numbers_left ltx_lstlisting" data="Zm9yIGk6PW1heGludCB0byAwIGRvCmJlZ2luCiAgeyBkbyBub3RoaW5nIH0KZW5kOw==" dataencoding="base64" datamimetype="text/plain" framecolor="#FF0000" framed="rectangle">
377+
<listing backgroundcolor="#FF5EFF" class="ltx_lst_language_Pascal ltx_lst_numbers_left ltx_lstlisting" cssstyle="padding:3.0pt" data="Zm9yIGk6PW1heGludCB0byAwIGRvCmJlZ2luCiAgeyBkbyBub3RoaW5nIH0KZW5kOw==" dataencoding="base64" datamimetype="text/plain" framecolor="#FF0000" framed="rectangle">
378378
<listingline xml:id="lstnumberx39"><tags>
379379
<tag>1</tag>
380380
<tag role="refnum">1</tag>
@@ -420,7 +420,7 @@ and with messed up braces <text class="ltx_lst_numbers_left ltx_lstlisting"><tex
420420
<tag role="typerefnum">line 4</tag>
421421
</tags><text class="ltx_lst_keyword" font="bold">end</text>;</listingline>
422422
</listing>
423-
<listing class="ltx_lst_language_Pascal ltx_lst_numbers_left ltx_lstlisting" data="Zm9yIGk6PW1heGludCB0byAwIGRvCmJlZ2luCiAgeyBkbyBub3RoaW5nIH0KZW5kOw==" dataencoding="base64" datamimetype="text/plain" framed="rectangle">
423+
<listing class="ltx_lst_language_Pascal ltx_lst_numbers_left ltx_lstlisting" cssstyle="padding:3.0pt" data="Zm9yIGk6PW1heGludCB0byAwIGRvCmJlZ2luCiAgeyBkbyBub3RoaW5nIH0KZW5kOw==" dataencoding="base64" datamimetype="text/plain" framecolor="#000000" framed="rectangle">
424424
<listingline xml:id="lstnumberx47"><tags>
425425
<tag>1</tag>
426426
<tag role="refnum">1</tag>
@@ -444,7 +444,7 @@ and with messed up braces <text class="ltx_lst_numbers_left ltx_lstlisting"><tex
444444
</listing>
445445
</para>
446446
<para xml:id="S7.p3">
447-
<listing class="ltx_lst_language_Pascal ltx_lst_numbers_left ltx_lstlisting" data="Zm9yIGk6PW1heGludCB0byAwIGRvCmJlZ2luCiAgeyBkbyBub3RoaW5nIH0KZW5kOw==" dataencoding="base64" datamimetype="text/plain" framed="topbottom">
447+
<listing class="ltx_lst_language_Pascal ltx_lst_numbers_left ltx_lstlisting" cssstyle="padding:3.0pt" data="Zm9yIGk6PW1heGludCB0byAwIGRvCmJlZ2luCiAgeyBkbyBub3RoaW5nIH0KZW5kOw==" dataencoding="base64" datamimetype="text/plain" framecolor="#000000" framed="topbottom">
448448
<listingline xml:id="lstnumberx51"><tags>
449449
<tag>1</tag>
450450
<tag role="refnum">1</tag>
@@ -475,7 +475,7 @@ and with messed up braces <text class="ltx_lst_numbers_left ltx_lstlisting"><tex
475475
</tags>
476476
<toccaption><tag close=" ">2</tag>A C language listing</toccaption>
477477
<caption><tag close=": ">Listing 2</tag>A C language listing</caption>
478-
<listing backgroundcolor="#E6E6E6" class="ltx_lst_language_C ltx_lst_numbers_left ltx_lstlisting" data="I2RlZmluZSBFWEFNUExFIHdoaWNod2hhdAp4ID0gImZvbyI7CmJyZWFrOw==" dataencoding="base64" datamimetype="text/plain" framed="topbottom">
478+
<listing backgroundcolor="#E6E6E6" class="ltx_lst_language_C ltx_lst_numbers_left ltx_lstlisting" cssstyle="padding:3.0pt" data="I2RlZmluZSBFWEFNUExFIHdoaWNod2hhdAp4ID0gImZvbyI7CmJyZWFrOw==" dataencoding="base64" datamimetype="text/plain" framecolor="#000000" framed="topbottom">
479479
<listingline xml:id="lstnumberx55"><tags>
480480
<tag>1</tag>
481481
<tag role="refnum">1</tag>

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)