标题颜色变为fgcolor(knitr,Rnw)

标题颜色变为fgcolor(knitr,Rnw),r,knitr,rnw,R,Knitr,Rnw,将knitr与Rnw文件一起使用时,在块中创建的标题字体的颜色将变为fgcolor 这个问题类似于。在这种情况下,此解决方案没有用处 有没有办法解决这个问题?Hacking knit_hooks$set(plot=myfunction)?如何? 多谢各位 % Minimal.Rnw \documentclass{tufte-book} \begin{document} Color of normal font is black. <<fig.env='marginfigure',fi

将knitr与Rnw文件一起使用时,在块中创建的标题字体的颜色将变为fgcolor

这个问题类似于。在这种情况下,此解决方案没有用处

有没有办法解决这个问题?Hacking knit_hooks$set(plot=myfunction)?如何? 多谢各位

% Minimal.Rnw
\documentclass{tufte-book}
\begin{document}
Color of normal font is black.
<<fig.env='marginfigure',fig.cap="The color of the font of the caption is fgcolor">>=
plot(1:10)
@
\begin{marginfigure}
    \caption{This color is black.}
\end{marginfigure}
\end{document}

如果R代码块生成的绘图存储在
文件夹中,则这应该满足您的要求:

\documentclass{tufte-book}
\begin{document}
Color of normal font is black.
<<test1, fig.show = 'hide'>>=
plot(1:10)
@

\begin{marginfigure}
\includegraphics[width = \textwidth]{figure/test1-1}
\caption{this is now the correct color}
\end{marginfigure}

\begin{marginfigure}
    \caption{This color is black.}
\end{marginfigure}
\end{document}

非常感谢。我没有考虑自己写环境。另一种可能是重新定义fgcolor(\definecolor{fgcolor}{rgb}{0,0,0}),但我不确定此更改如何影响块的突出显示。我只是编辑了我的答案,以添加另一种可能更好的可能性。重新定义
fgcolor
不会影响这个简单示例中的语法突出显示。
\documentclass{tufte-book}
\begin{document}
Color of normal font is black.
<<test1, fig.show = 'hide'>>=
plot(1:10)
@

\begin{marginfigure}
\includegraphics[width = \textwidth]{figure/test1-1}
\caption{this is now the correct color}
\end{marginfigure}

\begin{marginfigure}
    \caption{This color is black.}
\end{marginfigure}
\end{document}
\documentclass{tufte-book}
\definecolor{fgcolor}{RGB}{0,0,0}
\begin{document}
Color of normal font is black.
<<fig.env='marginfigure',fig.cap="The color of the font of the caption is fgcolor">>=
plot(1:10)
@
\begin{marginfigure}
    \caption{This color is black.}
\end{marginfigure}
\end{document}