Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latex tables verbatim #226

Closed
3 tasks done
raffdoc opened this issue May 22, 2019 · 8 comments
Closed
3 tasks done

Latex tables verbatim #226

raffdoc opened this issue May 22, 2019 · 8 comments
Milestone

Comments

@raffdoc
Copy link

raffdoc commented May 22, 2019

ASA_Journal.pdf
Hi,
I am using ASA template and putin insice a compareGroups generated table like this:

---
title: Title here

# to produce blinded version set to 1
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:
- 3 to 6 keywords
- that do not appear in the title

abstract: |
  The text of your abstract.  200 or fewer words.

bibliography: bibliography.bib
output: rticles::asa_article
....
---
# Introduction

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.__



```{r, results= 'asis', echo=FALSE, warning=FALSE, message=FALSE}
library(compareGroups)
data("predimed")
restab <- createTable(compareGroups(group ~ age + sex + smoke + 
    waist + hormo, data = predimed))
export2latex(restab)
```


In the latex outpus it puts verbatim{} araund latex code. I can no figure aout why.

`% !TeX program = pdfLaTeX
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx,psfrag,epsf}
\usepackage{enumerate}
\usepackage{natbib}
\usepackage{textcomp}
\usepackage[hyphens]{url} % not crucial - just used below for the URL
\usepackage{hyperref}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

%\pdfminorversion=4
% NOTE: To produce blinded version, replace "0" with "1" below.
\newcommand{\blind}{0}

% DON'T change margins - should be 1 inch all around.
\addtolength{\oddsidemargin}{-.5in}%
\addtolength{\evensidemargin}{-.5in}%
\addtolength{\textwidth}{1in}%
\addtolength{\textheight}{1.3in}%
\addtolength{\topmargin}{-.8in}%

%% load any required packages here

\begin{document}

\def\spacingset#1{\renewcommand{\baselinestretch}%
{#1}\small\normalsize} \spacingset{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\if0\blind
{
\title{\bf Title here}

\author{
Author 1 \thanks{The authors gratefully acknowledge \ldots{}} \
Department of YYY, University of XXX\
and \ Author 2 \
Department of ZZZ, University of WWW\
}
\maketitle
} \fi

\if1\blind
{
\bigskip
\bigskip
\bigskip
\begin{center}
{\LARGE\bf Title here}
\end{center}
\medskip
} \fi

\bigskip
\begin{abstract}
The text of your abstract. 200 or fewer words.
\end{abstract}

\noindent%
{\it Keywords:} 3 to 6 keywords, that do not appear in the title
\vfill

\newpage
\spacingset{1.45} % DON'T change the spacing!

\hypertarget{introduction}{%
\section{Introduction}\label{introduction}}

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.

\citet{Campbell02} \citeauthor{Schubert13}
\citetext{\citeyear{Schubert13}; \citealp{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. \textbf{With this spacing we
have 30 lines per page.}

\begin{verbatim}
\begin{longtable}{lcccc}\caption{Summary descriptives table by groups of `Intervention group'}\
\hline
& Control & MedDiet + Nuts & MedDiet + VOO & \multirow{2}{*}{p.overall}\
\end{verbatim}

& N=2042 & N=2100 & N=2182 & \textbackslash{}

\begin{verbatim}
\hline
\hline
\endfirsthead
\multicolumn{5}{l}{\tablename\ \thetable{} \textit{-- continued from previous page}}\
\hline
& Control & MedDiet + Nuts & MedDiet + VOO & \multirow{2}{*}{p.overall}\
\end{verbatim}

& N=2042 & N=2100 & N=2182 & \textbackslash{}

\begin{verbatim}
\hline
\hline
\endhead
\hline
\multicolumn{5}{l}{\textit{continued on next page}} \
\endfoot
\multicolumn{5}{l}{} \
\endlastfoot
Age & 67.3 (6.28) & 66.7 (6.02) & 67.0 (6.21) & 0.003 \
\end{verbatim}

Sex: & & & & $\textless{}$0.001 \textbackslash{} (\qquad)Male &
812 (39.8%) & 968 (46.1%) & 899 (41.2%) & \textbackslash{}
(\qquad)Female & 1230 (60.2%) & 1132 (53.9%) & 1283 (58.8%) &
\textbackslash{} Smoking: & & & & 0.444 \textbackslash{}
(\qquad)Never & 1282 (62.8%) & 1259 (60.0%) & 1351 (61.9%) &
\textbackslash{} (\qquad)Current & 270 (13.2%) & 296 (14.1%) &
292 (13.4%) & \textbackslash{} (\qquad)Former & 490 (24.0%) & 545
(26.0%) & 539 (24.7%) & \textbackslash{} Waist circumference & 101
(10.8) & 100 (10.6) & 100 (10.4) & 0.045 \textbackslash{}
Hormone-replacement therapy: & & & & 0.850 \textbackslash{}
(\qquad)No & 1811 (98.3%) & 1835 (98.4%) & 1918 (98.2%) &
\textbackslash{} (\qquad)Yes & 31 (1.68%) & 30 (1.61%) & 36
(1.84%) & \textbackslash{}

\begin{verbatim}
\hline
\end{longtable}
\end{verbatim}

\bibliographystyle{agsm}
\bibliography{bibliography.bib}

\end{document}
`
By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rticles'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rticles').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises

@yihui
Copy link
Member

yihui commented May 22, 2019

Please do not ignore the Github issue guide when you file issues.

@raffdoc
Copy link
Author

raffdoc commented May 23, 2019

@yihui I ave used issue guide, could you have a look?

@yihui
Copy link
Member

yihui commented May 23, 2019

You didn't format your issue correctly. Please use fenced code blocks to write verbatim content: https://yihui.name/issue/#please-format-your-issue-correctly

@raffdoc
Copy link
Author

raffdoc commented May 23, 2019

@yihui I want to avoid verbatim, I look for latex output. But it puts verbatim code. I don’t know why. Any idea?

@yihui
Copy link
Member

yihui commented May 23, 2019

I said "You didn't format your issue correctly." I mean your Github issue. I'm not ready to help you until you format it correctly. With the current format, I cannot simply copy and run your example. Please do read the issue guide. If there is anything unclear in the issue guide, please let me know.

@raffdoc
Copy link
Author

raffdoc commented May 24, 2019

@yihui Now It could be correct. Sorry.

@yihui yihui added this to the v0.8 milestone May 28, 2019
@yihui
Copy link
Member

yihui commented May 28, 2019

Sorry, but this is a question instead of a bug, so please follow the issue guide above:

If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.

The answer would be knitr::raw_latex(), and I don't have time to type out a full answer (hopefully someone else will).

@yihui yihui closed this as completed May 28, 2019
@github-actions
Copy link

github-actions bot commented Nov 2, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants