【问题标题】:how do you programatically create sub sections in latex/sweave你如何以编程方式在乳胶/编织中创建子部分
【发布时间】:2016-01-23 05:40:34
【问题描述】:

我有超过 100 个应用程序以及每个应用程序的 CPU 和性能数据。我需要检查我的数据集并为所有这些应用程序创建 CPU 和内存图表。每个应用都需要有自己的 pdf 部分。

假设我有一个这样的应用程序向量:

app<-c("Web", "Farm1", "Farm2", "Pod1")

如何以编程方式为每个应用创建小节并插入 CPU 和内存?

输出可能是这样的:

1. Webb
           cpu chart
           memory chart
2. Farm1
          cpu chart
          memory chart 

我试过了:

\documentclass{article}

\begin{document}
\title{applications cpu and memory}
\SweaveOpts{concordance=TRUE}
\tableofcontents

<<results='asis'>>=
   for (product in app){ 
    cat(paste("\\section{",product,"}", sep="")) }
    @


    \end{document}

当我尝试编译为 pdf 时出现此错误:

Writing to file ddd.tex
Processing code chunks with options ...
Error in match.arg(options$results, c("verbatim", "tex", "hide")) : 
  'arg' should be one of "verbatim", "tex", "hide"
Calls: <Anonymous> -> SweaveParseOptions -> check -> match.arg
Execution halted

有什么想法吗?

【问题讨论】:

    标签: r latex rstudio sweave


    【解决方案1】:

    你很接近,只需输入Sweave

    <<results=tex>>=
    

    而不是(knitr's)

    <<results='asis'>>=
    

    或者,使用knitr。为此,您可能需要在现有文件上调用 Sweave2knitr()

    有关参考,请参阅Sweave manual,第 13 页或knitr chunk options

    【讨论】:

    • @Hi Max,我还有一个问题。我想遍历该 for 循环中的每个应用程序并打印出 ggplot 输出。我做 p
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-08
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2019-10-17
    相关资源
    最近更新 更多