r - 在图的顶部编织标题
问题描述
我想在图形上方显示标题。我四处寻找一些解决方案,但我仍然无法实现我的目标。这是我的代码:
\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}
解决方案
您需要使用 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
在这种简单模式下不会为您添加。
推荐阅读
- gradle - 设置不粘在任务之间
- python - SENDGRID:使用 python 使用事务模板发送电子邮件?
- javascript - 是否可以使用像 vaadin-grid 这样的网格模板来自定义 vis.js 中的“组”列?
- c# - 生成没有特殊字符的唯一字符串
- vb.net - 无法将控件重命名为我删除的控件
- nosql - RavdnDb 自动索引
- javascript - 如何在组件中注入超过 1.5 倍的 Angular js 版本的服务?
- ios - 在从初始化程序返回之前,不会在所有路径上调用“super.init”
- python - Tensorflow:使用 argmax 对张量进行切片
- powershell - 如何使用 powershell 和 azure 函数创建 VM