如何在xtable标题中插入换行符? [英] How do I insert a line break in an xtable caption?

查看:87
本文介绍了如何在xtable标题中插入换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这是一个简单的解决方案,但我整天都在努力寻找解决方案.我要做的就是将xtable标题分成两行.我尝试了\ n和caption.width都无济于事.

I'm sure it's a simple solution but Ive been searching all day trying to solve this. All I want to do is split an xtable caption over 2 lines. I've tried \n and caption.width to no avail.

\documentclass{article}

\usepackage{caption}

\begin{document}

<<makedata,echo=TRUE,results='asis'>>=
df <- matrix(round(rnorm(9, 20, 10)), 3, 3)
colnames(df) <- c("Column1","Column2","Column3")
require(xtable)
print (xtable(df, caption="Title1\nTitle2"),caption.placement="top")
@




\end{document} 

推荐答案

我认为您需要\\\\,以便它将在tex文件中以\\的形式打印出来,从而创建换行符.

I think you need \\\\ so that it will print out in the tex file as \\ which creates a line break.

print (xtable(df, caption="Title1\\\\Title2"),caption.placement="top")

这篇关于如何在xtable标题中插入换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆