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?
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 ?).
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.
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.