exclude xurl package from latex file

Hi, in a R Markdown document I put [solution/cereal.R](solution/cereal.R) which translate in the LaTeX file to \url{solution/cereal.R}. In the PDF the link text becomes 13579/:solution/cereal, the link URL itself is correct.

The problem is that the xurl package is used when available: \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available. It seems that there is a bug in xurl; see hyperref - 'Uneven' breaks in long URLs (\url) - TeX - LaTeX Stack Exchange . When I delete the \IfFileExists...line then only the urlpackage is used and the link text and the link URL are correct.

How can I exclude the use of xurl in the LaTeX file?

Thanks Sigbert

For a one-time correction you could save the intermediate tex-file, edit this file and compile it. I am aware that this might not be your ideal solution.

output:
   pdf_document:
     keep_tex: yes

But apparently this is what you did (otherwise how could you know the usage of xurl ?).

A more rigorous approach would be to make a copy of the pandoc template that is used
and change that and use that template from now on.
See template_pandoc in R Markdown: The Definitive Guide for how to do that.
Then try https://raw.githubusercontent.com/jgm/pandoc-templates/master/default.latex as a starting point.

What is the current issue exactly ? The post is 3 years old.

The line with xurl comes from Pandoc templates that R Markdown uses

If there is really an issue with using it, the template should be updated there. Currently only way to remove that line for R Markdown would be to modify the template, or uninstall xurl before rendering.

I added in the YAML header under pdf_document a template: template.latexwith the modified template and it worked like a charm. Thanks, Sigbert

That would be the solution for a modified template indeed !

Pay attention that you won't get future update and you need to maintain yourself.

Can I ask what is the current exact issue ? Still the same as this :
hyperref - 'Uneven' breaks in long URLs (\url) - TeX - LaTeX Stack Exchange ?

I would like to know to maybe adapt our template or report to Pandoc. Thank you

Ulrike Fischer said in a comment "The numbers are due to a bug in xurl. It is adding all numbers to \UrlSpecials, but without a second argument and that breaks them.", However, I checked my pdflatex version and it is from TeXLive 2018. So, there might be a more recent TeXLive version which has a fixed xurl style file.

Additionally, Heiko Oberdiek commented in another post that solution/cereal.R is not a valid URI, although most browser will transform it in something valid; but there is no defined standard way to transform it. So, I'am not sure if really an action from your side is necessary.

Oh indeed. TeX Live has a new version each year, and CTAN is frozen for older version. So you are probably using an older version of xurl

Thanks for explaining!

I just tried it with TeXLive 2021 and it worked without a problem.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.