[英]knitr: Chapter name is the name of R chunk code
I want to use the R chunk code output as the Chapter Name but could not figured out how to do this. 我想使用R块代码输出作为“章节名称”,但无法弄清楚该如何做。 Below is my minimum working example. 以下是我的最低工作示例。
\documentclass{book}
\usepackage[T1]{fontenc}
\begin{document}
\chapter{cat(
<< label=Test1, echo=FALSE, results="asis">>=
2+1
@
)
}
Chapter name is the output of R chunk Code.
\end{document}
This works for me 这对我有用
<< label=Test1, echo=FALSE>>=
cn <- 2+1
@
\chapter*{Chapter \Sexpr{cn}}
在RMarkdown中,您可以使用以下代码
# `r I(1+2)`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.