Dealing with unicode characters in code

I have a rmd file, which include some special characters. Those characters are finely knitted in an html file, but not in a PDF.
pdflatex shows an error message and does not produce the pdf, while xelatex just omit the character (which is even worse).

I have seen that it is a common problem, but I could not find a satisfactory answer.

I have the character ≤ (less equal).
I could manually replace all ≤ with $\le$, but this would reduce the readability of the code.
I would prefer to tell markdown to replace ≤ with $\le$ before knitting in pdf, without having to do it manually, and without having to change the code I work on.

Is it possible?

Searching the internet I think your problem might be solved by using true-type fonts instead of the standaard ones.
See e.g. https://stackoverflow.com/questions/24421235/changing-font-in-pdf-produced-by-rmarkdown

Thanks for your suggestion.
However, I do not want to change the font of the document.

That is fine with me.
However a true-type font may exist that is very similar to the one your are using now and solves your problem.

This is indeed a right consideration, I shall check it out. Thanks!

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.