I am preparing R Markdown document in the pdf format. In the document I have a couple of tables. I used pander package to format tables. Suppose that I have data frame, DF, that I want to transform into table in the pdf output. To achieve that in a r code chunk I changed panderOptions for table caption prefix in order to print it in NON-English language and in the next line I call pander function with specified caption argument.
Here is relevant part of R Markdown code:
---
title: "Let's try!"
author: "Newbie_R"
date: "Monday, December 15, 2014"
output: pdf_document
---
```{r setoptions, echo = F, message=FALSE}
library (knitr)
library (pander)
opts_chunk$set(echo = F)
```
```{r DF}
vm <- 3/2 + 4/2
jl <- vm
ik <- 2+4
sr <- 3 + 4/2
lb <- 4
dk <- 3
zb <- 3
ss <- 2
DF <- data.frame (VM = vm,
JL = jl,
IK = ik,
SR = sr,
LB = lb,
DK = dk,
ZB = zb,
SS = ss)
```
Try to make a table!!!
```{r panderTable}
panderOptions("table.caption.prefix", "XXXXXX 1: ")
pander (DF, caption = "This is a very long table's title that should be printed above the table; Also, I would like format it to match boundaries of a length of the table")
```
The output is not the way I would like. I want to:
position table's title (caption) above the table
format length of table's title in a way that matches length of the table (wrap text within table's boundaries)
move table a bit bellow "Try to make a table!!!" text which is not a part of the r code chunk. Note that the "Try to make a table" text is more closer to the table compared to the table's title.
UPDATE1:
This link will direct to the original output. Instead to that one, I want to make something like this.
UPDATE2:
On this GitHub web page, one can find issue regarding option to place title on the top of a table. @daroczig said that it is not an issue connected with pander. However he suggested how it could be achieved. Where should I put code lines provided below which @daroczig suggested?
\usepackage{floatrow}
\floatsetup[table]{capposition=top}
\floatsetup[figure]{capposition=top}