【问题标题】:sweave caption on top of the figure在图的顶部编织标题
【发布时间】:2019-04-29 10:09:39
【问题描述】:

我想在图形上方显示标题。我四处寻找一些解决方案,但我仍然无法实现我的目标。 这是我的代码:

\documentclass{article}
\usepackage{caption}

\begin{document}

<<fig1, echo = F, fig.width=7, fig.height=5, fig.cap= "This is a caption">>=
x = 1:50
y = x^2
plot(x, y)
@

\end{document}

【问题讨论】:

    标签: r knitr sweave


    【解决方案1】:

    你需要使用 LaTeX 方法添加标题,knitr 不会自动添加。例如,

    \documentclass{article}
    \usepackage{caption}
    
    \begin{document}
    
    \begin{figure}
    \caption{This is a caption}
    <<fig1, echo = F, fig.width=7, fig.height=5>>=
    x = 1:50
    y = x^2
    plot(x, y)
    @
    \end{figure}
    
    \end{document}
    

    如果您跳过fig.cap 选项,您只会插入图形,而不是作为 LaTeX 浮动图形,但您仍然可以将其放入自己的浮动中。如果您想引用该图,您可能需要显式添加\label,因为knitr 在这种简单模式下不会为您添加。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      • 1970-01-01
      • 2013-12-20
      相关资源
      最近更新 更多