【问题标题】:KnitR , Latex conditional display of Text and Code blockKnitR,Text 和 Code 块的 Latex 条件显示
【发布时间】:2014-06-19 17:04:23
【问题描述】:

如何根据某些条件打开/关闭特定小节的显示? 例如,我只想在xyplotFacSpecTotVarTest.pdf 存在时显示以下子部分。

我该怎么做?

\subsection{Checksum: Factor, Specific, and Total Variance}
Perhaps the most basic test of a regression model is if the factor and specific variances sum to equal the total variance.  Here, we 
present this diagnostic as an xy-plot, with the sum of factor and specific variance on the x-axis and the total variance on the y-axis.  We 
expect the plotted points to line up tightly along the identity line.

\clearpage
\begin{figure}[!h]

\centering

\includegraphics{\Sexpr{image_dir}xyplotFacSpecTotVarTest.pdf}

\caption{Total Variance vs. Sum of Factor and Specific Variance, All Instruments Passing Exposure Model.}

\end{figure}

【问题讨论】:

  • 如何处理“xyplotFacSpecTotVarTest.pdf”不存在的情况。文件从表中的内容生成,而表中可能有也可能没有数据。如果缺少“xyplotFacSpecTotVarTest.pdf”,最终的 PDF 生成过程会出错 我该如何处理这种情况?

标签: r latex knitr pdflatex


【解决方案1】:

将您的子部分放在不同的文件中,例如 sub.Rnw。然后有条件地将其包含在您的主文档中,例如

<<child = if (file.exists('foo.pdf')) 'sub.Rnw'>>=
@

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-01
    • 2015-09-29
    • 2019-04-14
    • 2017-08-04
    • 1970-01-01
    • 2013-09-28
    • 2016-01-27
    • 2016-11-14
    相关资源
    最近更新 更多