Hi!
I had the exact same problem yesterday and I think I've found a (somewhat hacky) solution today.
Explanation
The command that gets executed depending on what you set for org-preview-latex-default-process
(in our case 'imagemagick
) can be seen in the variable org-preview-latex-process-alist
under :image-converter
. Its default value is the following:
((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 -o %O %f")
:transparent-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 --no-fonts --exact-bbox --scale=%S --output=%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")))
Here we see that preview runs convert -density %D -trim -antialias %f -quality 100 %O"
.
Further down in the Documentation there is an explanation of the place-holders used:
Place-holders used by :image-converter and :latex-compiler:
%f input file name
%b base name of input file
%o base directory of input file
%O absolute output file name
Place-holders only used by :image-converter:
%D dpi, which is used to adjust image size by some processing commands.
%S the image size scale ratio, which is used to adjust image size by some
processing commands.
I don't know much about ImageMagick but what I think is happening is %D
(intended by emacs as a placeholder for DPI) is already in use by Imagemagick (as 'image GIF dispose method', source).
Hacky Solution
I simply set the DPI in the above :image-converter
command of imagemagick explicitly. i.e. the -density
flag to something like 150:
...
(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 150 -trim -antialias %f -quality 100 %O")))
Addendum
Remember that preview caches the generated images by default (I think). To test if this works remember to either (1) use a new latex fragment to preview
or (2) delete the image cache (cache location is defined by org-preview-latex-image-directory
)