【问题标题】:How do I insert a line break in an xtable caption?如何在 xtable 标题中插入换行符?
【发布时间】:2013-11-12 19:14:11
【问题描述】:

我确信这是一个简单的解决方案,但我整天都在寻找试图解决这个问题。我要做的就是将 xtable 标题拆分为 2 行。我试过 \n 和 caption.width 无济于事。

\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} 

【问题讨论】:

  • 使用乳胶换行符 `\\` 有效吗?

标签: r latex knitr sweave


【解决方案1】:

我认为您需要 \\\\ 以便它在 tex 文件中打印为 \\ 从而创建换行符。

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

【讨论】:

    【解决方案2】:

    Sam 的回答让我朝着正确的方向前进,但我不得不使用 \\newline 而不是 \\\\,因为我收到有关溢出框的乳胶错误。也许不同之处在于我正在动态生成我的字幕:

    title <- paste("some text","\\newline",sep='')
    print(xtable(df, caption=title))
    

    【讨论】:

      猜你喜欢
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      相关资源
      最近更新 更多