Bastien <b...@altern.org> writes:

> Hi Daimrod,
>
> Daimrod <daim...@gmail.com> writes:
>
>> Is there an #+STARTUP parameter to automatically display LaTeX
>> fragments?
>
> Nope, sorry.

Here is a patch to add `org-startup-with-latex-preview'. It should work
like `org-startup-with-inline-images'.

diff --git a/doc/org.texi b/doc/org.texi
index 030eaf8..a13d565 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -9752,6 +9752,19 @@ some aspects of the preview.  In particular, the @code{:scale} (and for HTML
 export, @code{:html-scale}) property can be used to adjust the size of the
 preview images.
 
+@vindex org-startup-with-latex-preview
+You can turn on the previewing of all @LaTeX{} fragments of a file with
+
+@example
+#+STARTUP: latexpreview
+@end example
+
+To disable it, simply use
+
+@example
+#+STARTUP: nolatexpreview
+@end example
+
 @node CDLaTeX mode,  , Previewing @LaTeX{} fragments, Embedded @LaTeX{}
 @subsection Using CD@LaTeX{} to enter math
 @cindex CD@LaTeX{}
diff --git a/lisp/org.el b/lisp/org.el
index effb231..2e7f3a4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -580,6 +580,16 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-startup-with-latex-preview nil
+  "Non-nil means preview LaTeX fragments when loading a new Org file.
+
+This can also be configured on a per-file basis by adding one of
+the followinglines anywhere in the buffer:
+   #+STARTUP: latexpreview
+   #+STARTUP: nolatexpreview"
+  :group 'org-startup
+  :type 'boolean)
+
 (defcustom org-insert-mode-line-in-empty-file nil
   "Non-nil means insert the first line setting Org-mode in empty files.
 When the function `org-mode' is called interactively in an empty file, this
@@ -4509,6 +4519,8 @@ After a match, the following groups carry important information:
     ("noalign" org-startup-align-all-tables nil)
     ("inlineimages" org-startup-with-inline-images t)
     ("noinlineimages" org-startup-with-inline-images nil)
+    ("latexpreview" org-startup-with-latex-preview t)
+    ("nolatexpreview" org-startup-with-latex-preview nil)
     ("customtime" org-display-custom-times t)
     ("logdone" org-log-done time)
     ("lognotedone" org-log-done note)
@@ -5154,6 +5166,8 @@ The following commands are available:
 	(set-buffer-modified-p bmp)))
     (when org-startup-with-inline-images
       (org-display-inline-images))
+    (when org-startup-with-latex-preview
+      (org-preview-latex-fragment))
     (when org-startup-indented
       (require 'org-indent)
       (org-indent-mode 1))
-- 
Daimrod/Greg

Attachment: pgpgs1Ek3Eswb.pgp
Description: PGP signature

Reply via email to