簡體   English   中英

是否可以為代碼塊生成的表(而非圖)設置fig.scap?

[英]Is it possible to set fig.scap for table (instead for figure) genrated by a code chunk?

我有一個由編織代碼塊生成的表。 該表是使用xtable打印的。 它的標題設置在xtable函數中。 該標簽太長,無法在文檔開頭的表格列表中顯示。 因此,我想設置一個短標簽,代替此列表中的長標簽。

對於生成的圖,可以通過塊選項fig.scap設置此標簽,但是當我嘗試將其用於表格時,長標簽仍保留在表格列表中。

我認為我可以在代碼塊之外使用\\captionof{table}[short label]{long label}來處理此問題,但這不是一種非常簡單的方法,我擔心卡住表和它的標題在一起。 有更好的方法嗎?

代碼(包含人工數據):

\documentclass[a4paper,12pt, english]{article}

\usepackage{capt-of}

\begin{document}
\listoffigures
\listoftables
\section{Intoduction}
<<Chunk1, results="asis", echo=FALSE, fig.scap= "short caption - tab">>=
library(xtable)
print(xtable(head(iris), caption="long caption of the table"))
@

<<Chunk2, results="asis", echo=FALSE,fig.align="center", fig.cap = "Long caption of the figure", fig.scap= "short caption - fig">>=
plot(iris[,1:2])
@

\end{document}

要定義在“ xtable列表”中使用的“簡短標題”,請將長度為2的字符向量傳遞給xtablecaption參數。 ?xtable

caption :長度為1或2的字符向量,包含表的標題或標題。 如果length為2,則第二項是LaTeX生成“表列表”時使用的“短標題”

例:

\documentclass{article}
\begin{document}
\listoftables
<<echo = FALSE, results = "asis">>=
xtable::xtable(head(iris), caption = c("Long Caption", "Short"))
@
\end{document}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM