harrelfe / Hmisc

Harrell Miscellaneous
Other
205 stars 81 forks source link

Latex call included in pdf output when using 'latex' on 'summaryM'-object #88

Open tormodb opened 6 years ago

tormodb commented 6 years ago

Dear Prof. Harrel.

I am currently experiencing an issue when using latex on a summaryM object and producing pdf output. The latex call is included in the text:

%latex.default(cstats, title = title, file = file, append = TRUE, caption = finalcaption, rowlabel = rowlabel, table.env = (!tabenv1 && table.env) || (tabenv1 && istr == 1), col.just = col.just, numeric.dollar = FALSE, insert.bottom = finallegend, rowname = lab, dcolumn = dcolumn, extracolheads = extracolheads, extracolsize = NNsize, insert.top = if (strat != “.ALL.”) strat, ...)%

This issue seems related to what has been reported previously (issue #75 - last comment) and in the pull request ('Add a flag to omit the output of commented call when using latex'). It does not resolve (for me) by using `KnitrSet()' .

I attach a reproducible example below (to be compiled as an rmd file):

---
title: "Hmisc::summaryM - latex call in knitr output"
author: ""
date: 
output:
  pdf_document: default
abstract: 'Example demonstrating latex call being included in pdf output when using Hmisc::latex on summaryM table.'
---
library(Hmisc)

Without 'knitrSet'

tblex <- summaryM(disp+ hp + drat+ wt~cyl, data = mtcars)
Hmisc::latex(tblex, digits = 2, prmsd = T, brmsd = F, long = T, what = "%", 
             formatArgs=list(big.mark   = " "), table.env = T, booktabs = F, 
             file="", npct.size = "small", size = "small", legend.bottom = T, 
             middle.bold = T, where="!htbp")

With 'knitrSet' (makes no difference to this particular problem)

knitrSet(lang = 'markdown')
Hmisc::latex(tblex, digits = 2, prmsd = T, brmsd = F, long = T, what = "%", 
             formatArgs=list(big.mark   = " "),table.env = T, booktabs = F, 
             file="", npct.size = "small", size = "small", legend.bottom = T, 
             middle.bold = T, where="!htbp")
tormodb commented 6 years ago

I also attach the produced pdf here to illustrate the output.

LatexCallIncluded.pdf

harrelfe commented 6 years ago

Not sure this should have been a new issue. And please get to the bottom of whatever is breaking valid lines produced by latex().