SOLVED: REMOVE #+SETUPFILE:
HEADER. SORRY FOR WASTING YOUR TIME
I am having the same issue as described in this Reddit post from a few weeks ago: basically the preview images generated for a given latex fragment in the file are too large vertically and make the file unreadable.
I started out using dvipng
(the default) to generate the images.
I've played around with adding
(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
to my config: this made the rendered latex larger (which was helpful) but unfortunately did not cut down the size of the images (which in fact got larger).
I've also tried switching form dvipng
to dvisvgm
, the latter just gave the error
Latex-preview not working; Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’
like in this post.
Finally, I have also tried the texfrag
package, which kind of works, but only after setting the scale and generating previews, getting an error, and then generating previews again. It doesn't work with #+STARTUP: latexpreview
.
EDIT:
As requested, here is a brief snippet of an org-roam
file that produces unwieldy previews:
#+title: Kullback-Leibler divergence
#+roam_tags: "machine learning" "statistics" "probability"
* Kullback-Leibler Divergence
For two continuous probability distributions of one dimension $P$ and $Q$, the Kullback-Leibler (KL) divergence, also known as the relative entropy, gives a measure of the difference between them. The definition is as follows:
\begin{eqnarray}
\label{eq:KL}
D_Q(P) = \int_{\infty}^{\infty} dx ~ P(x) \log \left(frac{P(x)}{Q(x)} \right) \,,
\end{eqnarray}
from which we can see that the KL divergence is not symmetric - $D_Q(P)$ is a measure of the divergence of $P$ from $Q$, while $D_P(Q)$ measures the divergence of $Q$ from $P$, and these are in general different.
(I don't think org-roam
has anything to do with this, just a handy example)
EDIT2: Emacs 27.2 and Org mode version 9.4.4
GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4) of 2021-03-26
Org mode version 9.4.4 (release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/)
EDIT3:
Here is the current setup of org-preview-latex-process-alist
:
Value:
((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"))
(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")))
$x=1$
or some longer\begin{equation} ... \end{equation}
block, and the result persists. See also the example given in the linked Reddit post.emacs -q
(i.e. without your init file) and see if you can reproduce it. If not, then some setting in your init file is causing this. Also post the version of emacs and Org mode you are using (M-x emacs-version
andM-x org-version
resp).emacs -q
still gives the previews that are oversized (again, the text is correctly sized but the image dimensions are too large)