Closed MLopez-Ibanez closed 9 hours ago
Thanks, it is sensible to fix this. The simplest would be to replace \slash
with /
. A complete Rd solution could be based on \if{latex} ... else ...
.
It may take some time as the teaching is starting.
No hurry, I just wanted to document this issue somewhere.
Did you get the warning in the title when building (the documentation of) a package?
A reproducible example (for testing a fix later):
slash_bib <- charToBib('@misc{key,
title = "Something\\slash Something",
author = "John Smith",
}', direct = TRUE)
## this is a simplified version of what insert_ref does:
toRd(slash_bib)
## [1] "Smith J (????).\n\\dQuote{Something\\slash Something.}"
slash_bib
## Smith J (????). "Something\slash Something."
print(slash_bib, style = "html")
## <p>Smith J (????).
## “Something\slash Something.”
## </p>
print(slash_bib, style = "latex")
## Smith J (????).
## ``Something\bsl{}slash Something.''
It looks like a new Rdmacro \slash
, which conditionally export /
or \slash
might be the most suitable solution.
I fixed this in Rdpack, see above.
The current solution is to emit an ifelse
instruction which keeps \slashfor latex but replaces it with slash,
/`, otherwise.
For the record, a solution based on introducing a new Rd macro \slash
does not work for 'pkgdown' as that doesn't use user macros for parsing Rd, except when initially reading the Rd file. So, it the text returned by the reference macros contains a user macro like \slash
, its definition is not passed on to the parser. Also, although it works for the various formats of R documentation (produced by R), it would be tricky to gobble the whitespace after \slash
in a macro.
More testing is needed, please feel free to reopen the issue if something is wrong.
It seems
rbibutils
does not convert\slash
to/
when translating from BibTeX to Rd. The main difference between writing/
and\slash
in LaTeX is that "and/or" will never allow a linebreak after "/" but "and\slash or" does allow it" (not sure how to express this in Rd format).