2

By using pdfkit-pythonbased on wkhtmltopdf, I have managed to convert MathJaxinto pdf. wkhtmltopdf configuration options are the following:

options = {
    'quiet': '',
    'javascript-delay' : '5000',
    'page-size': 'A4',
    'margin-top': '0.75in',
    'margin-right': '0.75in',
    'margin-bottom': '0.75in',
    'margin-left': '0.75in',
    'disable-smart-shrinking': '',
    'dpi': '400',
}

This allows to obtain the markdown text that is large as expected, however maths do not scale accordingly.

Here a snapshot of the pdf obtained :

mathJax to pdf yield tiny maths

where maths appears definitely too small.

And here how it is rendered on the browser:

enter image description here

Any idea on how to tackle the problem, in other words obtain maths scaling with the markdown text in the pdf output, will be greatly appreciated.

Here below the MathJax config:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    TeX: {extensions: ["mhchem.js"]},
    tex2jax: {
    inlineMath: [['$','$'], ['\\(','\\)']],
    displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    processEscapes: true
    }
});
</script>

<script type="text/javascript" async
    src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
mannaia
  • 860
  • 2
  • 11
  • 27

1 Answers1

1

Found a solution, by adding the following to MathJaxconfiguration:

MathJax.Hub.Config({
    CommonHTML: {
        minScaleAdjust: 100,
    }
});

thus increasing to 100% while default value is only 50 %. Reference is here.

mannaia
  • 860
  • 2
  • 11
  • 27
  • I didn't understand WHERE did you put that code. I am downloading HTML files from the internet, so that would be very cumbersome and complicated to modify the HTML file before passing it to wkhtmltopdf (but I am not using pdfkit, just the command line directly) – robertspierre Jul 23 '18 at 13:14
  • 1
    I've put those instructions on the main html file, through which all pdf conversions are done. – mannaia Jul 23 '18 at 19:40