Closed avyukt closed 4 years ago
This is rather a pandoc, or even more a LaTeX question and not really specific to the pander
wrapper, but if you can share a minimal example, I can try to look into that.
---
title: "Put tables on the same page"
author: "author"
date: May 16, 2020
output:
pdf_document:
extra_dependencies: ["lipsum"]
number_sections: yes
toc: yes
geometry: margin=1in
fontsize: 11pt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
cache = TRUE,
#include = FALSE,
message = FALSE,
warning = FALSE,
error = TRUE,
fig.cap = " ",
number_sections = TRUE)
```{r}
library(tidyverse)
library(pander)
library(markdown)
#panderOptions('keep.trailing.zeros', TRUE)
```
\lipsum[3-5]
```{r}
m5 = lm(log(Volume)~log(Girth)*log(Height)+Girth^2+Girth^3+Girth^4 +
Height^2+Height^3+rnorm(31)+rpois(31, 1),data=trees)
pander(m5)
```
I tried adding the file in .Rmd format but it is converting it to the code above. Would you be able to add the Rmd tags? or how shall I add the minimal example in Rmd format? Thank you.
Please check if this file downloads and replace the extension with .Rmd. It only allows certain file formats to be uploaded here. I want the table to be on the same page.
I tried getting the .tex file from .Rmd and replace longtable with booktabs but it is not working directly. There are too many tables to change each of them manually.
The problem I think is because the latex code uses longtable which spans multiple pages. Is there a way to change the package used for tables to booktabs or some other option with Rmarkdown or pander?
Hm, this does render on a single page for me:
Anyway, sorry, I have to close this -- as not being in the scope of pander
. This R package helps with transforming R objects into Pandoc's markdown, and then it's pandoc
doing the document conversion, eg into tex
and then calling pdflatex
(or similar) for the PDF output. I'd ask on the pandoc
email list.
Could you please share the session info? As I am getting the table to be on two pages. Maybe there is some package or library that is interfering with the latex compilation.
Thank you.
R and packages:
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux
Matrix products: default
BLAS: /usr/lib/libblas.so.3.9.0
LAPACK: /usr/lib/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pander_0.6.3
loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3 Rcpp_1.0.3 digest_0.6.25
pandoc:
$ pandoc -v
pandoc 2.9.2
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2
Default user data directory: /home/daroczig/.local/share/pandoc or /home/daroczig/.pandoc
Copyright (C) 2006-2019 John MacFarlane
Web: https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
pdflatex:
$ pdflatex -v
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/Arch Linux)
kpathsea version 6.3.1
Copyright 2019 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with poppler version 0.87.0
PS worst case scenario if the R->markdown->tex conversion path is not working, I'd suggest looking into xtable
etc for greater control on the LaTeX output
I have been using pander to generate a report with more than 20 summary tables from old output. The tables are short enough to fit within a page but when creating pdf from Rmd document, the tables break on to two pages.
Since there are so many of them, I cannot use the option of \pagebreak to force them on a new page or manually place them.
What pander option or method can I use to keep the tables on the same page?