I need to export my org notes containing latex to HTML format. Example document :
#+latex_class: article
#+latex_header: \usepackage{chemfig}
#+latex_header: \usepackage[version=3]{mhchem}
#+latex_compiler: pdflatex
#+options: tex:t
#+date: \today
#+title: something
#+author: me
$$U_l=\frac{-A}{6}\Bigg[\frac{2}{\alpha^2-4}+\frac{2}{\alpha^2}+\ln{\Big(\frac{\alpha^2-4}{\alpha^2}\Big)}\Bigg]$$
$$\ce{Zn^2+ <=>[+ 2OH-][+ 2H+] $\underset{\text{amphoteres Hydroxid}}{\ce{Zn(OH)2
v}}$ <=>[+ 2OH-][+ 2H+] $\underset{\text{Hydroxozikat}}{\ce{[Zn(OH)4]^2-}}$}$$
$$\chemfig{C*3(---)}$$
As I am using chemfig
and other packages, using mathjax #+options: tex:t
(default), won't render them in the HTML page:
Now I have two methods to solve this, either to use dvipng or dvisvgm.
Using dvipng
To use dvipng, I changed mathjax to #+options: tex:dvipng
, however as it can be seen, it does not render chemfig
(and few other like tikz
) properly (instead of 'C', there should have been a cyclopropane molecule) :
Imagemagick
also shows the same behaviour. So my first question is : how can I get dvipng
to render the correct output?
Using dvisvgm
Next I tried to use dvisvgm
using #+options: tex:dvisvgm
, and while it renders everything correctly, It also scales the images to almost the full width of the page :
However I can fix this by modifying .org-svg { width: 90%; }
to .org-svg { width: auto; }
in the HTML source code as mentioned here. So my second question would be : How can I implement this setting for all org files whenever I export to HTML automatically? (as doing it manually each time I export would be tedious).
My third question would be that is it possible to use mathjax
for normal math and dvipng
/dvisvgm
for other packages like packages like chemfig
in the HTML output?
Please also suggest if there is another method to achieve this..