diff --git a/lib/LaTeXML/Engine/TeX_Box.pool.ltxml b/lib/LaTeXML/Engine/TeX_Box.pool.ltxml index 56ae014d9..856baada0 100644 --- a/lib/LaTeXML/Engine/TeX_Box.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Box.pool.ltxml @@ -415,7 +415,11 @@ sub insertBlock { DefConstructor('\vbox BoxSpecification VBoxContents', sub { my ($document, $spec, $contents, %props) = @_; - my @block = insertBlock($document, $contents, vattach => 'bottom'); }, + # Note: passing in empty block_props allows insertBlock to unwrap the container node entirely, + # which is often desired in cases such as \unvbox, + # and can be requested by setting "_unwrapped_block". + my %block_props = $props{'_unwrapped_block'} ? () : (vattach => 'bottom'); + my @block = insertBlock($document, $contents, %block_props); }, sizer => '#2', properties => { layout => 'vertical', vattach => 'bottom' }, mode => 'text', @@ -432,7 +436,8 @@ DefConstructor('\vbox BoxSpecification VBoxContents', sub { DefConstructor('\vtop BoxSpecification VBoxContents', sub { my ($document, $spec, $contents, %props) = @_; - insertBlock($document, $contents, vattach => 'top'); }, + my %block_props = $props{'_unwrapped_block'} ? () : (vattach => 'top'); + insertBlock($document, $contents, %block_props); }, sizer => '#2', properties => { layout => 'vertical', vattach => 'baseline' }, mode => 'text', @@ -574,13 +579,23 @@ DefPrimitive('\unhbox Number', sub { my $stuff = LookupValue($box); adjustBoxColor($stuff); AssignValue($box, undef); - (defined $stuff ? $stuff->unlist : List()); }); + if (ref $stuff eq 'LaTeXML::Core::Whatsit') { + $stuff->setProperty("_unwrapped_block" => 1); + return $stuff; + } else { + return (defined $stuff ? $stuff->unlist : List()); +} }); DefPrimitive('\unhcopy Number', sub { my $box = 'box' . $_[1]->valueOf; my $stuff = LookupValue($box); adjustBoxColor($stuff); - (defined $stuff ? $stuff->unlist : List()); }); + if (ref $stuff eq 'LaTeXML::Core::Whatsit') { + $stuff->setProperty("_unwrapped_block" => 1); + return $stuff; + } else { + return (defined $stuff ? $stuff->unlist : List()); +} }); # \unvbox<8bit>, \unvcopy<8bit> DefPrimitive('\unvbox Number', sub { @@ -588,13 +603,23 @@ DefPrimitive('\unvbox Number', sub { my $stuff = LookupValue($box); adjustBoxColor($stuff); AssignValue($box, undef); - (defined $stuff ? $stuff->unlist : List()); }); + if (ref $stuff eq 'LaTeXML::Core::Whatsit') { + $stuff->setProperty("_unwrapped_block" => 1); + return $stuff; + } else { + return (defined $stuff ? $stuff->unlist : List()); +} }); DefPrimitive('\unvcopy Number', sub { my $box = 'box' . $_[1]->valueOf; my $stuff = LookupValue($box); adjustBoxColor($stuff); - (defined $stuff ? $stuff->unlist : List()); }); + if (ref $stuff eq 'LaTeXML::Core::Whatsit') { + $stuff->setProperty("_unwrapped_block" => 1); + return $stuff; + } else { + return (defined $stuff ? $stuff->unlist : List()); +} }); #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Various box related parameters diff --git a/t/alignment/vmode.pdf b/t/alignment/vmode.pdf index 84bb2dc4d..3acc5a968 100644 Binary files a/t/alignment/vmode.pdf and b/t/alignment/vmode.pdf differ diff --git a/t/alignment/vmode.tex b/t/alignment/vmode.tex index 638a39100..d260dbf5f 100644 --- a/t/alignment/vmode.tex +++ b/t/alignment/vmode.tex @@ -84,4 +84,18 @@ \section{Graphics rescaling} \scalebox{3}[2]{\includegraphics{foo}} +\section{unvbox and unvcopy} +% +\newbox\boxA +\newbox\boxB +\newbox\boxC +\newbox\boxD +\newbox\boxE +\setbox\boxA=\vbox spread 1cm{1cm Box} +\setbox\boxB=\vbox spread 2cm{2cm Box} +\setbox\boxC=\vbox{\unvcopy\boxA\unvcopy\boxB} +\setbox\boxD=\vbox{\unvbox\boxA\unvbox\boxB} +\setbox\boxE=\vbox{\unvbox\boxC\unvbox\boxD} +% +via unvbox, unvcopy: \fbox{\box\boxE} \end{document} \ No newline at end of file diff --git a/t/alignment/vmode.xml b/t/alignment/vmode.xml index c618ee2d6..283702621 100644 --- a/t/alignment/vmode.xml +++ b/t/alignment/vmode.xml @@ -205,4 +205,20 @@ This is random text. This is random text. This is random text.

+
+ + 5 + 5 + ยง5 + + <tag close=" ">5</tag>unvbox and unvcopy + +

via unvbox, unvcopy: +

1cm Box

+

2cm Box

+

1cm Box

+

2cm Box

+

+
+