carpentries / assessment

This repository contains assessment data, source code, and analyses for The Carpentries workshops and programmatic assessment.
https://carpentries.github.io/assessment/
Other
5 stars 7 forks source link

tables don't render well when publishing to pdf via nbconvert #2

Open fmichonneau opened 6 years ago

fmichonneau commented 6 years ago

From @maneesha on May 17, 2018 19:6

See:

https://github.com/carpentries/assessment/blob/master/programmatic-assessment/workshops/outputs/sample_report.pdf

Table formatting gets thrown off.

Tables do render well in html:

http://htmlpreview.github.io/?https://github.com/carpentries/assessment/blob/master/programmatic-assessment/workshops/outputs/sample_report.html

Copied from original issue: carpentries/assessment#199

fmichonneau commented 6 years ago

From @tbekolay on May 21, 2018 18:52

Any chance you could include the .tex file that produces the .pdf? That should make it obvious why the table is misformatted.

fmichonneau commented 6 years ago

From @maneesha on May 21, 2018 20:1

@tbekolay The pdfs and htmls are built using nbconvert See the readme in this project for the flags I've been using

fmichonneau commented 6 years ago

From @rgaiacs on May 24, 2018 13:43

@maneesha Could you break the notebook in a minimal example? It always helps to track the problem down.

fmichonneau commented 6 years ago

From @maneesha on May 24, 2018 16:51

@rgaiacs Check out the test_mini notebook in the test_notebook branch

The corresponding html and pdf outputs are in the outputs folder. The markdown table doesn't seem to get squished, but the pandas df table still does not show in the pdf.

fmichonneau commented 6 years ago

From @grahamalama on May 25, 2018 3:21

I've found that that importing:

from IPython.display import HTML, Math

and wrapping the tables that you want to output like:

display(Math(DataFrame.to_latex()))

at least produces tables, but they don't always look pretty.

You might need to export the notebook as latex first, manually edit the latex, then find a way to convert the latex to a PDF. Alternatively, you could export the notebook to HTML, apply custom CSS/JS, then save the HTML file as a PDF.

fmichonneau commented 6 years ago

From @maneesha on June 12, 2018 20:1

Workaround - I've been printing the html to pdf in my browser. Keeping this issue open in case anyone has other suggestions.