arXiv / html_feedback

Supports a student project developing a UI for feedback on arXiv articles rendered as html.
MIT License
18 stars 3 forks source link

Arguments to macro show as text in arXiv HTML version of article #258

Open ghenter opened 10 months ago

ghenter commented 10 months ago

Description

We use a macro to make bold text with the same spacing/kerning as regular text bold, for alignment in tables that mix bold and non-bold numbers. The macro is defined as \newcommand{\tablebf}[1]{\pdfliteral direct {2 Tr 0.5 w}#1\pdfliteral direct {0 Tr 0 w}}. Unfortunately, it does not work in the HTML version of arXiv. For example, invoking the macro as \tablebf{14.8M} incorrectly shows "2 Tr 0.5 w14.8M0 Tr 0 w" on the HTML page, whereas the PDF correctly shows only the text "14.8M" in bold.

(Optional:) Please add any files, screenshots, or other information here.

Screenshot from Overleaf of our exact macro code, for reference:

image

Screenshot from HTML version of article, showing the error:

image

Screenshot from rendered PDF, showing the expected result:

image

(Required) What is this issue most closely related to? Select one.

Other

Internal issue ID

Since this field was not set automatically, I am entering text so that "Submit new issue" can be clicked.

Paper URL

Since this field was not set automatically, I am entering text so that "Submit new issue" can be clicked.

Browser

Since this field was not set automatically, I am entering text so that "Submit new issue" can be clicked.

Device Type

Since this field was not set automatically, I am entering text so that "Submit new issue" can be clicked.

github-actions[bot] commented 10 months ago

Hello @ghenter, thanks for the issue report! We are reviewing your report and will address it as soon as possible.

dginev commented 10 months ago

Currently latexml tries to simply ignore \pdfliteral directives.

We could enhance latexml to recognize this case, but you're dangerously close to being in PDF-only territory.

This kind of macro may benefit from the \iflatexml conditional when it becomes available, to use the simpler bold directives already supported by latexml in the HTML context, while still using the PDF-optimized variant for PDF.

davidcarlisle commented 10 months ago

a more portable and idiomatic latex way to get unextended bold would be \fontseries{b}\selectfont (rather than bx) see for example

https://tex.stackexchange.com/questions/410739/align-numbers-based-on-the-decimal-point-with-textbf-and-stars-in-the-table/410741#410741

that isn't to say latexml shouldn't try to handle the pdftex specific markup that already exists in existing documents but simply ignoring it would be acceptable here I think.

ghenter commented 10 months ago

Thanks for these insightful and helpful responses! I will look into the method suggested by @davidcarlisle for the future.

Also, apologies if this was a known WONTFIX/duplicate; the arXiv HTML preview encouraged me to submit an error report if I spotted any issues, so that's what I did. :)

I am closing the issue, but you may reopen it if you deem it relevant.

davidcarlisle commented 10 months ago

up to the latexml team but I wouldn't have closed this. In general latexml (or any convertor) is going to have to handle all kinds of tex markup, so just because there may be better markup that could have been used doesn't mean that the system shouldn't do something reasonable with whatever markup is actually there.

dginev commented 10 months ago

I agree the issue should have stayed open: this is just some friendly exploratory discussion on our part @ghenter .

I don't have sufficient permissions to reopen, but I know who to ask...

chrisjcameron commented 10 months ago

Thanks for the discussion. This project has an ambitious goal and we know it will be more of a marathon than a sprint. I really appreciate the feedback from authors and readers -- it helps us identify and prioritize issues.

u-fischer commented 10 months ago

You could use the pdfrender package instead of the primitive. This has the benefit that it would support also lualatex (and perhaps later other engines) and would probably allow latexml to provide an alternative:

\documentclass{book}
\usepackage{pdfrender}
\newcommand\tablebf[1]{\textpdfrender{TextRenderingMode=FillStroke,LineWidth=0.5}{#1}}
\begin{document}
blub \tablebf{some text} more text
\end{document}

This inserts the same literals into the PDF:

2 Tr
0.5 w
 [-333(some)-334(text)]TJ
0 Tr
1 w

and gives this as output

image