Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\unvbox and friends request a block unwrap #2459

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions lib/LaTeXML/Engine/TeX_Box.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -574,27 +579,47 @@ 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 {
my $box = 'box' . $_[1]->valueOf;
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
Expand Down
Binary file modified t/alignment/vmode.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions t/alignment/vmode.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
16 changes: 16 additions & 0 deletions t/alignment/vmode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,20 @@ This is random text. This is random text. This is random text.</p>
</inline-block>
</para>
</section>
<section inlist="toc" xml:id="S5">
<tags>
<tag>5</tag>
<tag role="refnum">5</tag>
<tag role="typerefnum">§5</tag>
</tags>
<title><tag close=" ">5</tag>unvbox and unvcopy</title>
<para xml:id="S5.p1">
<p>via unvbox, unvcopy: <inline-block framed="rectangle" vattach="bottom">
<p>1cm Box</p>
<p>2cm Box</p>
<p>1cm Box</p>
<p>2cm Box</p>
</inline-block></p>
</para>
</section>
</document>
Loading