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

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

Open
ghenter opened this issue Jan 9, 2024 · 8 comments
Open

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

ghenter opened this issue Jan 9, 2024 · 8 comments
Labels

Comments

@ghenter
Copy link

ghenter commented Jan 9, 2024

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.

Copy link

github-actions bot commented Jan 9, 2024

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

@dginev
Copy link

dginev commented Jan 9, 2024

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
Copy link

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
Copy link
Author

ghenter commented Jan 9, 2024

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.

@ghenter ghenter closed this as completed Jan 9, 2024
@davidcarlisle
Copy link

davidcarlisle commented Jan 9, 2024

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
Copy link

dginev commented Jan 10, 2024

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 chrisjcameron reopened this Jan 10, 2024
@chrisjcameron
Copy link
Collaborator

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
Copy link

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

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

No branches or pull requests

6 participants