knitr kable: Text color in PDF from RNW is grey

↘锁芯ラ 提交于 2021-01-27 07:05:52

问题


When I create a table using the knitr::kable function within a RNW file, the text color of the table items in the PDF appears to be grey.

I would like to change this to black. How can I do this?


回答1:


\documentclass{article}
\begin{document}
<<>>=
  knitr::kable(cars[1:10,]) # grey
@

<<results="asis">>=
  knitr::kable(cars[1:10,]) # black
@
\end{document}

By default, the output of kable will be wrapped in a knitrout environment where the text color (fgcolor) is set to grey (rgb: 0.345, 0.345, 0.345). This is what happens in the first chunk.

With results="asis", the output is not wrapped in any enclosing environment, leaving the text color unchanged (black).



来源:https://stackoverflow.com/questions/41404116/knitr-kable-text-color-in-pdf-from-rnw-is-grey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!