Note: This summary can be maxed with other summary calls where a line every row is needed, so a solution that puts lines between every row of every table will not work. Need it just for the tables I'm creating.
Using latest RStudio, I have an object type for which summary.type produces Pandoc output of a table. I would like to, in pdf / LaTeX output, have a horizontal line between each row of the table. All my attempts fail with the error :
! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.207 \hline
pandoc: Error producing PDF from TeX source
Given the following in a .md file:
------------------------------------------------------------------------------------------------
term estimate std.error statistic p.value N adj.rsq
------------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
**1** NA 26.8 0.766 35 0 1466 0.004
**2** NA 0.012 0.012 0.939 0.348 . .
-------------------------------------------------------------------------------------------------
Another option is to add labels after you have created the table
\hline
And executing the following command (created by RStudio):
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS type.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output type.pdf --table-of-contents --toc-depth 3 --template ~/Library/R/3.2/library/rmarkdown/rmd/latex/default-1.14.tex --highlight-style tango --latex-engine /Library/TeX/texbin/pdflatex --variable graphics=yes --variable 'geometry:margin=1in'
Remove that last line (the "\hline") and everything compiles correctly.
When I create html instead of pdf, the \hline is ignored (as it should be) and the file is created successfully.
What am I doing wrong? What is the minimum LaTeX I can embed in my Pandoc output in order to have a line with each row of a table?
Attempted solutions:
- Use \hrulefill: Problem: Will only fill 90% of a single column. Putting it in every column doesn't fill the line
- Use "---" to tell Pandoc I need a horizontal line: Problem: Ends the table
- Change LaTeX template so every row of every table has a line separating it: Problem: Only want to does this for the rows created by summary.myType, not for all tables anywhere in the document
Attempted solutions and results:
------------------------------------------------------------------------------------------------
term estimate std.error statistic p.value N adj.rsq
------------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
**1** NA 26.8 0.766 35 0 1466 0.004
\hrulefill \hrulefill \hrulefill \hrulefill \hrulefill \hrulefill \hrulefill \hrulefill
**2** NA 0.012 0.012 0.939 0.348 . .
---
**3** NA -0.718 0.291 -2.469 0.014 . .
-------------------------------------------------------------------------------------------------
Another option is to add labels after you have created the table