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

color from surrounding scope overrides colors inside boxes #2455

Open
xworld21 opened this issue Dec 23, 2024 · 2 comments · May be fixed by #2456
Open

color from surrounding scope overrides colors inside boxes #2455

xworld21 opened this issue Dec 23, 2024 · 2 comments · May be fixed by #2456

Comments

@xworld21
Copy link
Contributor

This was quite difficult to pin down. Emitting a box apparently inherits the surrounding colour, overriding whatever happens in the box.

\documentclass{article}
\newbox\mybox
\usepackage{xcolor}
\begin{document}
  \color{black}

  \global\setbox\mybox=\vbox{The final word should be \textcolor{green}{green}}
  \box\mybox
\end{document}

You get

<document xmlns="http://dlmf.nist.gov/LaTeXML">
  <resource src="LaTeXML.css" type="text/css"/>
  <resource src="ltx-article.css" type="text/css"/>
  <para vattach="bottom" xml:id="p1">
    <p><text color="#000000">The final word should be green</text></p>
  </para>
</document>

If I remove \color{black}, I get the expected

<document xmlns="http://dlmf.nist.gov/LaTeXML">
  <resource src="LaTeXML.css" type="text/css"/>
  <resource src="ltx-article.css" type="text/css"/>
  <para vattach="bottom" xml:id="p1">
    <p>The final word should be <text color="#00FF00">green</text></p>
  </para>
</document>

(Context: I am experimenting with reading beamer raw. Against all odds, it actually works, except that all colours are missing due to this bug!)

@dginev dginev added this to the LaTeXML-0.8.9 milestone Dec 23, 2024
@xworld21
Copy link
Contributor Author

Ah, now that I know what the bug is, I can also find the source:

sub adjustBoxColor_internal {
my ($color, $box) = @_;
if (my $font = $box->getFont) {
$box->setFont($font->merge(color => $color)); }
return; }

This function should skip the boxes whose colour is already specified.

@dginev dginev linked a pull request Dec 23, 2024 that will close this issue
@dginev
Copy link
Collaborator

dginev commented Dec 24, 2024

@xworld21 just a brief comment - I believe the last 3 issues you've opened in the LaTeXML repository may be the best 3 issues to have ever been opened here. Precise reporting, minimal examples and with exact code references, I'm genuinely impressed. You're making our lives very easy!

It took me very little effort to make sample PRs addressing the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants