I successfully use org LaTeX-preview to have my formulas displayed as images in my org-mode documents. There is one problem I am facing, though: I need the LaTeX math font to be upright instead of slanted. This is easily solved in an ordinary LaTeX-document by adding \usepackage[math-style=upright]{unicode-math}
. For some reason, I have trouble getting it to work with LaTeX preview. This is my package specification for preview images:
(setq org-latex-packages-alist '(
("" "amssymb" t)
("" "turnstile" t) ; for Turnstiles
("" "centernot" t) ; for striked through Turnstiles
("" "mathpartir" t) ; for inference patterns
("math-style=upright" "unicode-math" t) ; for upright Math font
))
If I understand how org-latex-packages-to-string
works, the above specification should produce the desired result. I even manually added "\usepackage[math-style=upright]{unicode-math}" to org-format-latex-header
:
(setq org-format-latex-header "\\documentclass{article}
\\usepackage[usenames]{color}
\[PACKAGES]
\[DEFAULT-PACKAGES]
\\usepackage[math-style=upright]{unicode-math} % added package
\\pagestyle{empty} % do not remove
% The settings below are copied from fullpage.sty
\\setlength{\\textwidth}{\\paperwidth}
\\addtolength{\\textwidth}{-3cm}
\\setlength{\\oddsidemargin}{1.5cm}
\\addtolength{\\oddsidemargin}{-2.54cm}
\\setlength{\\evensidemargin}{\\oddsidemargin}
\\setlength{\\textheight}{\\paperheight}
\\addtolength{\\textheight}{-\\headheight}
\\addtolength{\\textheight}{-\\headsep}
\\addtolength{\\textheight}{-\\footskip}
\\addtolength{\\textheight}{-3cm}
\\setlength{\\topmargin}{1.5cm}
\\addtolength{\\topmargin}{-2.54cm}"
)
This did not work either. Do you have an idea what I can do to have the LaTeX-fragments displayed upright instead of slanted?
Edit:
The value of org-preview-latex-process-alist
is
((dvipng :programs
("latex" "dvipng")
:description "dvi > png" :message "you need to install the programs: latex and dvipng." :image-input-type "dvi" :image-output-type "png" :image-size-adjust
(1.0 . 1.0)
:latex-compiler
("latex -interaction nonstopmode -output-directory %o %f")
:image-converter
("dvipng -D %D -T tight -bg Transparent -o %O %f"))
(dvisvgm :programs
("latex" "dvisvgm")
:description "dvi > svg" :message "you need to install the programs: latex and dvisvgm." :image-input-type "dvi" :image-output-type "svg" :image-size-adjust
(1.7 . 1.5)
:latex-compiler
("latex -interaction nonstopmode -output-directory %o %f")
:image-converter
("dvisvgm %f -n -b min -c %S -o %O"))
(imagemagick :programs
("latex" "convert")
:description "pdf > png" :message "you need to install the programs: latex and imagemagick." :image-input-type "pdf" :image-output-type "png" :image-size-adjust
(1.0 . 1.0)
:latex-compiler
("pdflatex -interaction nonstopmode -output-directory %o %f")
:image-converter
("convert -density %D -trim -antialias %f -quality 100 %O")))
Also, I have (setq org-latex-create-formula-image-program 'dvipng)
in my .init file. This is why the value of org-preview-latex-default-process
is dvipng
.
org-preview-latex-process-alist
andorg-preview-latex-default-process
? Also, you shouldn't be usingamssymb
together withunicode-math
.unicode-math
afteramssymb
.unicode-math
works only with XeLaTeX or LuaLaTeX, it does not work with plain LaTeX which is what your configuration uses. I am able to get upright math without any problems, but I usexelatex
and notlatex
. I get an error if I attempt to uselatex
.unicode-math
andamssymb
together: They serve the same purpose and clash with each other. See e.g. tex.stackexchange.com/questions/175860/….