hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
321 stars 28 forks source link

quick_pdf prints to whole page #81

Closed tingleyd closed 6 years ago

tingleyd commented 6 years ago

I'm using quick_pdf to create a pdf of a regression table, that I then want to use in a latex document. However, when it prints, it prints an entire page, and even puts in a page number.

I tried adjusting borders, but as expected this didn't have an impact.

collected<-huxreg(u,i, ii, statistics = c(N = "nobs", "BIC")) quick_pdf(collected, file = "IntenseRegressions.pdf", borders=.1)

u, i, and ii are just objects from lm()

Is there a way to write a .pdf file that is only the regression table and nothing else around it?

IntenseRegressions.pdf

hughjonesd commented 6 years ago

quick_pdf is supposed to create a PDF, and it does that. Why don't you use huxreg within a markdown document?

tingleyd commented 6 years ago

Thanks David,

Unfortunately in some contexts I can't use markdown. It would be a great feature to be able to export a pdf of a table that isn't a full page and is scaled to the table's size. I understand this might be outside of your interest and thank you for developing open source software.

best, Dustin

Dustin Tingley Government Department Harvard University http://scholar.harvard.edu/dtingley

On Thu, Aug 16, 2018 at 1:18 AM, David Hugh-Jones notifications@github.com wrote:

quick_pdf is supposed to create a PDF, and it does that. Why don't you use huxreg within a markdown document?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hughjonesd/huxtable/issues/81#issuecomment-413428784, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr12l-OAqtzVYgIkVfMdY8iOpT9IqRkks5uRQDCgaJpZM4V-0iv .

hughjonesd commented 6 years ago

Alternatives: knitr, or just print_latex and add your own TeX code around it. -- Sent from Gmail Mobile

hughjonesd commented 6 years ago

To be fair, if there is a reason to have a simple table in a PDF for inclusion in another PDF document, say so. My thought was that this would always be just to do a quick report. But maybe sometimes LaTeX uses child documents? If so, then I would consider a pull request. -- Sent from Gmail Mobile

tingleyd commented 6 years ago

Hi David,

The workflow is similar when one is producing a .pdf graphic (like from ggplot), and then sourcing that via \incldudegraphics within the latex document. I'd love to be able to do the same thing with regression tables. This way I can produce all figures/tables in R.

Of course, markdown, knitr are better approaches but some collaborators don't use R and author in latex. Some of which happens in overleaf as well.

I looked quick_pdf at I suspect the autosizing would be tricky. But anyways, hope this helps and thanks again for your great package.

Dustin

Dustin Tingley Government Department Harvard University http://scholar.harvard.edu/dtingley

On Thu, Aug 16, 2018 at 12:32 PM, David Hugh-Jones <notifications@github.com

wrote:

To be fair, if there is a reason to have a simple table in a PDF for inclusion in another PDF document, say so. My thought was that this would always be just to do a quick report. But maybe sometimes LaTeX uses child documents? If so, then I would consider a pull request.

-- Sent from Gmail Mobile

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hughjonesd/huxtable/issues/81#issuecomment-413606453, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr12sm6_XBnA-jyNTqFD2dFg1-JfgBjks5uRZ6JgaJpZM4V-0iv .

hughjonesd commented 6 years ago

Tell me what the requirements are for auto sizing. The table should always be \textwidth? -- Sent from Gmail Mobile

tingleyd commented 6 years ago

Hi David,

My intuition is to treat this as closely to how the pdf() driver in R does it, where you let the user set the size of the pdf file in width and height.

My best guess to do this is to just the geometry package in latex (users already need a miktex installation to run your pdf driver).

https://tex.stackexchange.com/questions/31973/latex-how-do-i-force-pdf-page-height-width

So users would pass in the width and height arguments

\usepackage[pass,paperwidth=8.5in,paperheight=11in]{geometry}

In your code it would go here I suspect.

tryCatch({ cat("\documentclass{article}\n") report_latex_dependencies() cat("\n\begin{document}") lapply(hts, function(ht) { cat("\n\n") print_latex(ht) cat("\n\n") })

This would avoid needing to auto detect, and would let users get however much white space padding they want.

This would then bring all the amazing styling people can do in huxtable to this other common latex/pdf workflow.

Dustin

Dustin Tingley Government Department Harvard University http://scholar.harvard.edu/dtingley

On Fri, Aug 17, 2018 at 1:55 AM, David Hugh-Jones notifications@github.com wrote:

Tell me what the requirements are for auto sizing. The table should always be \textwidth?

-- Sent from Gmail Mobile

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hughjonesd/huxtable/issues/81#issuecomment-413765340, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr12jEgstyF3PqbwXcS5vTAnp7LiuuLks5uRlrUgaJpZM4V-0iv .

hughjonesd commented 6 years ago

Ok, I'll look at this

hughjonesd commented 6 years ago

If you could try out github master and see if it works for what you need, that would be great. I am a bit loth to do this, because it adds complexity to `quick_pdf, but if you find this is worthwhile, I'm open to it. I've also removed page numbering.

tingleyd commented 6 years ago

Thanks so much.

I really do think this will be very helpful. I've spoken to several of my staff as well as graduate students and they completely agree. The additional options are minimal.

I tried it out and could not get the height and width changes to alter the .pdf file. Would you mind sharing the syntax you used in a quick_pdf() call?

In looking at the source code, it seems like it should work (the core sprintf call being cat(sprintf("\usepackage[%s]{geometry}\n", dim_string)))

Dustin Tingley Professor of Government Government Department Harvard University dustintingley.org

Faculty Director, Vice Provost on Advances in Learning (VPAL) Research Team http://vpal.harvard.edu/research

Check out: ABLConnect http://ablconnect.harvard.edu/, the Active and Activity Based Learning Connection, and Undergraduate Research Scholars http://urs.iq.harvard.edu/, Institute of Quantitative Social Science (Contribute to the Research Resource Reservoir http://urs.iq.harvard.edu/pages/research-resources)

dart.harvard.edu/about (Digital Assets for Reuse in Teaching)

On Fri, Aug 24, 2018 at 11:45 AM, David Hugh-Jones <notifications@github.com

wrote:

If you could try out github master and see if it works for what you need, that would be great. I am a bit loth to do this, because it adds complexity to `quick_pdf, but if you find this is worthwhile, I'm open to it. I've also removed page numbering.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hughjonesd/huxtable/issues/81#issuecomment-415799406, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr12nCwA1x1UfgMGgZ8HDqz-FIOzCuzks5uUB-NgaJpZM4V-0iv .

hughjonesd commented 6 years ago

height="4in",width="4in"

as args to quick_pdf. If that doesn't work, show an example call, and ideally use debug() to check what's being written to the TeX file.

On Fri, 24 Aug 2018 at 21:25, tingleyd notifications@github.com wrote:

Thanks so much.

I really do think this will be very helpful. I've spoken to several of my staff as well as graduate students and they completely agree. The additional options are minimal.

I tried it out and could not get the height and width changes to alter the .pdf file. Would you mind sharing the syntax you used in a quick_pdf() call?

In looking at the source code, it seems like it should work (the core sprintf call being cat(sprintf("\usepackage[%s]{geometry}\n", dim_string)))

Dustin Tingley Professor of Government Government Department Harvard University dustintingley.org

Faculty Director, Vice Provost on Advances in Learning (VPAL) Research Team http://vpal.harvard.edu/research

Check out: ABLConnect http://ablconnect.harvard.edu/, the Active and Activity Based Learning Connection, and Undergraduate Research Scholars http://urs.iq.harvard.edu/, Institute of Quantitative Social Science (Contribute to the Research Resource Reservoir http://urs.iq.harvard.edu/pages/research-resources)

dart.harvard.edu/about (Digital Assets for Reuse in Teaching)

On Fri, Aug 24, 2018 at 11:45 AM, David Hugh-Jones < notifications@github.com

wrote:

If you could try out github master and see if it works for what you need, that would be great. I am a bit loth to do this, because it adds complexity to `quick_pdf, but if you find this is worthwhile, I'm open to it. I've also removed page numbering.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/hughjonesd/huxtable/issues/81#issuecomment-415799406 , or mute the thread < https://github.com/notifications/unsubscribe-auth/ABr12nCwA1x1UfgMGgZ8HDqz-FIOzCuzks5uUB-NgaJpZM4V-0iv

.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/hughjonesd/huxtable/issues/81#issuecomment-415858965, or mute the thread https://github.com/notifications/unsubscribe-auth/AFjJ95Yz-cI1fTFcUdvZ4FztX5QNLSbvks5uUFMtgaJpZM4V-0iv .

-- Sent from Gmail Mobile

hughjonesd commented 6 years ago

Closed with the latest release. Please reopen if this isn't working for you.