Closed raffdoc closed 5 years ago
The export2latex
function creates LaTeX code to generate the table. However, it requires longtable
, multirow
and multicol
LaTeX packages. In addition,expot2latex
doesn't work properly on Rmd files (using knitr), but it must be used on RSweave (.Rnw) document. Below, there is a reproducible toy example Rnw code file.
If you want to compile Rmardown (.Rmd) document, use the export2md
function.
Hope it helps.
Isaac.
############# example.Rnw #############
\documentclass{article}
\usepackage{longtable} \usepackage{multirow} \usepackage{multicol}
\begin{document}
<
\end{document}
#####################
Tanks for rapid response.
There are some templates for scientific journals (rticles package from rstudio) that are written in rmarkdown put at the end converted to latex and pdf files.
Pity, it does not function. There is a this wierd \start{verbatim} \end{verbatim}
in the middle of the code.
I think if you can eliminate this behavior you will fix this issue.
Thanks
If you want to generate a PDF document with Rmarkdown (.Rmd) document, you can use the export2md
function. This function works for PDF, HTML and Word documents. Although it detects automatically in which format the file is compiled, you can set the argument format
to "latex" if the file is compiled to PDF.
I hope it works.
It does not do the trick. Thanks anyway.
Dear @isubirana
Here is a reproducable example.
title: Title here
blinded: 0
authors:
name: Author 1 thanks: The authors gratefully acknowledge ... affiliation: Department of YYY, University of XXX
name: Author 2 affiliation: Department of ZZZ, University of WWW
keywords:
abstract: | The text of your abstract. 200 or fewer words.
This template demonstrates some of the basic latex you'll need to know to create a ASA article.
\section{Verifications} \label{sec:verify} This section will be just long enough to illustrate what a full page of text looks like, for margins and spacing.
@Campbell02 @Schubert13 [@Chi81]
The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. With this spacing we have 30 lines per page.
library(compareGroups)
data("predimed")
restab <- createTable(compareGroups(group ~ age + sex + smoke +
waist + hormo, data = predimed))
export2latex(restab)
` You will find that wierd verbatim inside the latex table.
I couldn't reproduce your example and couldn't figure out the solution.
Could you send me the .Rmd file to my e-mail (isubirana
Isaac.
Hi Rafik,
Bellow, you will find the syntax with two little modifications (tagged with “ISAAC”). The strange behavior was caused by export2latex, as you mentioned. In compareGroups there are two function to export tables to PDF documents in a Rmarkdown file: export2latex and export2md. The latest (export2md) you have to specify the argument format=”latex”. The export2md function works fine under “knitr” (“.Rmd”), while expor2latex works fine with “sweave” (.Rnw) files. Clearly, this should be message to be included in the help manuals.
Let us know if it works, and many thanks for your feedback.
Regards,
Isaac.
######## code ##########
title: Title here
blinded: 0
authors:
name: Author 1 thanks: The authors gratefully acknowledge ... affiliation: Department of YYY, University of XXX
name: Author 2 affiliation: Department of ZZZ, University of WWW
keywords:
abstract: | The text of your abstract. 200 or fewer words.
output: rticles::asa_article header-includes:
This template demonstrates some of the basic latex you'll need to know to create a ASA article.
\section{Verifications} \label{sec:verify} This section will be just long enough to illustrate what a full page of text looks like, for margins and spacing.
The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. With this spacing we have 30 lines per page.
library(compareGroups)
data("predimed")
restab <- createTable(compareGroups(group ~ age + sex + smoke +
waist + hormo, data = predimed))
export2md(restab, format="latex") ## ISAAC> change the export2latex to export2md
I am tring to use export2 talex with rmarkdown file but id does not function. It puts out only a varbatim code but does not create a table itself.
export2latex(tab1demo,caption = "The main table")