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

hyperref.sty.ltxml throws error for \url containing underscores in \footnote #992

Closed
siegfriedzoetzsche opened this Issue May 8, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@siegfriedzoetzsche

siegfriedzoetzsche commented May 8, 2018

LaTeXML throws an

Error:unexpected:_ Script _ can only appear in math mode

for

    \documentclass{article}
    \usepackage{hyperref}
    \begin{document}
    \footnote{\url{url.with.under_score}}
    \end{document}

but does not complain about

    \documentclass{article}
    \usepackage{hyperref}
    \begin{document}
    \url{url.with.under_score}
    \footnote{\url{url.without.underscore}}
    \end{document}

or

    \documentclass{article}
    \usepackage{url}
    \begin{document}
    \footnote{\url{url.with.under_score}}
    \end{document}

Despite the error message, LaTeXML seems to produce correct output.

@dginev dginev added this to the LaTeXML-0.8.3 milestone May 8, 2018

@dginev

This comment has been minimized.

Collaborator

dginev commented May 8, 2018

Indeed, it seems that the hyperref binding keeps underscores as is? @brucemiller may know more, the relevant line is:

my @toks = map { (((($cc = $_->getCatcode) == CC_CS) || ($cc == CC_SUB)) ? $_ : T_OTHER(ToString($_))) } $url->unlist;

Thanks for the report and the pointed examples!

@dginev

This comment has been minimized.

Collaborator

dginev commented May 8, 2018

I have recently seen an increase with these

Error:unexpected:_ Script _ can only appear in math mode

errors while testing over recent batches of papers from arXiv, so a fix here may be an easy win for improving the statistics there.

@brucemiller

This comment has been minimized.

Owner

brucemiller commented May 10, 2018

Curious... that's part of it, but url.sty and hyperref.sty differ slightly, and the above doesn't quite capture the difference. I'll have to create some good tests (and testcases!)

@brucemiller

This comment has been minimized.

Owner

brucemiller commented May 10, 2018

Boy, once I started digging and comparing url & hyperref, and trying out tests, it got a bit messier. hyperref expands, url doesn't, which carries with it a few peculiarities. I think I've got it sorted out and added a couple of more thorough test cases. Thanks for the report!

(and hopefully it'll help arXiv as well :> )

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