使用wkhtmltopdf将MathJax转换为pdf会产生太小的数学运算 [英] Converting MathJax into pdf with wkhtmltopdf yields too small maths

查看:323
本文介绍了使用wkhtmltopdf将MathJax转换为pdf会产生太小的数学运算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过使用基于wkhtmltopdfpdfkit-python,我设法将MathJax转换为pdf. wkhtmltopdf配置选项如下:

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',
}

这允许获取markdown文本,该文本的大小与预期的一样大,但是数学无法相应地缩放.

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

以下是获取的pdf的快照:

Here a snapshot of the pdf obtained :

数学看上去肯定太小了.

where maths appears definitely too small.

以下是它在浏览器中的呈现方式:

And here how it is rendered on the browser:

任何有关如何解决该问题的想法,换句话说,可以使用pdf输出中的markdown文本获得数学缩放比例.

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.

下面是MathJax配置:

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>

推荐答案

找到了解决方案,方法是将以下内容添加到MathJax配置中:

Found a solution, by adding the following to MathJaxconfiguration:

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

因此增加到100%,而默认值仅为50%.参考是此处.

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

这篇关于使用wkhtmltopdf将MathJax转换为pdf会产生太小的数学运算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆