本文介绍了knitr:章节名称是R块代码的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用R块代码输出作为章节名称",但无法弄清楚该怎么做.下面是我的最低工作示例.
I want to use the R chunk code output as the Chapter Name but could not figured out how to do this. 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}
推荐答案
这对我有用
<< label=Test1, echo=FALSE>>=
cn <- 2+1
@
\chapter*{Chapter \Sexpr{cn}}
这篇关于knitr:章节名称是R块代码的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!