-
Notifications
You must be signed in to change notification settings - Fork 104
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
pgf layers do not get cleared #2412
Comments
Found the reason! This is the actual bug: \documentclass{article}
\newbox\myboxA
\newbox\myboxB
\begin{document}
\setbox\myboxA\vbox{A must appear once.}
\setbox\myboxB\vbox{B must appear once.}
\box\myboxA
\box\myboxA
\begingroup
\box\myboxB
\endgroup
\box\myboxB
\end{document} The PDF will show two boxes, LaTeXML will show three. This is because LaTeXML's |
Another facet of the same bug: changing color of a copy of a box changes the color of all the boxes, which has a funny time travelling effect. \copy\myboxA
{\color{red}\copy\myboxA}
\copy\myboxA All three boxes will be red! It looks like |
Really great to have this diagnostic, thank you! We should convert these snippets into new tests. The TeXbook mentions that
this is page 119 in Chapter 15. And indeed, |
It acts globally on the box, but not on the register, e.g. \documentclass{article}
\newbox\myboxC
\begin{document}
\setbox\myboxC\vbox{C must appear twice.}
\begingroup
\setbox\myboxC\vbox{C must appear twice.}
\box\myboxC
\endgroup
\box\myboxC
\end{document} should print two boxes. If you assign the register globally, you'll only get one. |
Ah I see, nice example. At least I would need a number of new tests here to make sure I'm not missing nuances. But the texbook is consistently discussing "box registers" and "voiding" box registers, rather than individual boxes (be they horizontal or vertical). Here is some more text on that, from page 120:
Exercise 15.11 touches on how magical that is (again for \global purposes):
So I am wondering if this also doesn't concern the exact scoping mechanics of the |
In C/Perl/Rust parlance, I think it boils down to the register being a reference to the box rather than the box, with Knuth says that this is a consequence of the lower-level implementation on page 119 'TEX [makes boxes void] for efficiency, since it is desirable to avoid copying the contents of potentially large boxes'. Note also how he says 'When you use a |
I am pretty sure I made a PR that addresses the limitation in latexml -- the I think we were simply missing a more precise method to unbind a single frame's assignments from the undo table. |
I haven't been able to fully decipher the web sources, but I suspect we are both slightly wrong. The To test this behaviour, we need a situation in which |
Quite possibly. Since you mention the web sources, I was also consulting them without much success, actually to some frustration, since there is a comment that is almost useful, but almost. In: procedure begin_box(@!box_context:integer);
label exit, done;
var @!p,@!q:pointer; {run through the current list}
@!m:quarterword; {the length of a replacement list}
@!k:halfword; {0 or |vmode| or |hmode|}
@!n:eight_bits; {a box number}
begin case cur_chr of
box_code: begin scan_eight_bit_int; cur_box:=box(cur_val);
box(cur_val):=null; {the box becomes void, at the same level}
end;
copy_code: begin scan_eight_bit_int; cur_box:=copy_node_list(box(cur_val));
end;
last_box_code: @<If the current list ends with a box node, delete it from
the list and make |cur_box| point to it; otherwise set |cur_box:=null|@>;
vsplit_code: @<Split off part of a vertical box, make |cur_box| point to it@>;
othercases @<Initiate the construction of an hbox or vbox, then |return|@>
endcases;@/
box_end(box_context); {in simple cases, we use the box immediately}
exit:end; The text the box becomes void, at the same level should really be the clear answer to our conundrum. But |
Indeed, same level as what? However, I just checked how |
A baffling scope bug, seemingly related to some issues reported on ar5iv. I spotted this in the atoms-and-orbitals test: the content of pgf layers (created via
pgfonlayer
) does not clear when closing a group.renders as
You can see that the black circle is still in the background layer even if it's a new image.
The text was updated successfully, but these errors were encountered: