LaTeXML icon indicating copy to clipboard operation
LaTeXML copied to clipboard

only adjust black color during box operations

Open dginev opened this issue 1 year ago • 2 comments

Fixes #2455 .

The issue is really excellent in scope and triage - I added the test case here as well.

That said, the resolution is just a little tricky, because I am not sure if there is a clear design for testing "a color having been set". I tried a couple of generic solutions, but kept losing test coverage. Then I saw we are using a Black->equals test to assert the default color scheme. As it turns out, using that test keeps all tests passing and also covers the reported example.

But I can't at all claim that I am certain this is the best approach.

dginev avatar Dec 23 '24 19:12 dginev

Hmm, you're right: being black doesn't mean that it wasn't explicitly set to black. I want to look a bit more...

brucemiller avatar Jan 22 '25 22:01 brucemiller

Hmm, you're right: being black doesn't mean that it wasn't explicitly set to black. I want to look a bit more...

There are a few packages that use Black (as opposed to ['rgb', 0, 0, 0] which is different). Grepping for Black brings up:

  • diagbox: Black is used as default linecolor
  • color/xcolor: use Black as default or if parsing/lookup fails
  • framed/makecell/ntheorem: use Black as framecolor
  • LaTeX.pool: uses Black as default color and as fill/stroke for \circle;
  • xy: uses Black as default color
  • wasysym: uses Black as background
  • Package.pm: uses Black if color lookup fail

So it seems safe to interpret Black as 'currentColor' (in SVG terminology); if TeX code explicitly sets the color to black, it will actually use ['rgb', 0, 0, 0]. With that in mind, it should really be called CurrentColor instead of Black (which would lead to a fix for #1541, by the way).

If anything, adjustBoxColor may have to adjust all other occurrences of Black too (linecolor, framecolor, background, fill, stroke) depending on how the normal TeX engines behave.

xworld21 avatar Jan 25 '25 18:01 xworld21