Inline Font color with {.class} are not correctly rendered in epub and pdf #5300
Answered
by
mcanouil
ma-bit-bot
asked this question in
Q&A
-
I'm formatting text with classes to give them custom colors. The classes are defined in a css-file. This works as expected by using {.class} when I output to HTML. But the formatting gets lost when I output to epub or pdf. How can I add the styles defined in the css-files to my pdf and epub outputs? |
Beta Was this translation helpful? Give feedback.
Answered by
mcanouil
Apr 25, 2023
Replies: 1 comment 3 replies
-
CSS is for HTML based format, thus it can't work for PDF. Note that is already discussed in #3496 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It also highlights a solution for PDF: #3496 (reply in thread).
PDF can't use CSS classes, because it would require to read/parse CSS classes and try to convert all the components to multiple languages.
You can use conditional contents, custom Lua filter to add colour, etc.
For example:
Using the Lua code from rstudio/rmarkdown-cookbook#368.