emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-latex-preview with custom sty file
@ 2023-02-24 17:25 chris
  2023-02-24 17:49 ` Timothy
  0 siblings, 1 reply; 3+ messages in thread
From: chris @ 2023-02-24 17:25 UTC (permalink / raw)
  To: emacs-orgmode

Dear all,

How to do it:

My org-latex-preview related config:

```
(with-eval-after-load 'org 
     (add-to-list 'org-latex-packages-alist '("" "stmaryrd" t)) 
     (add-to-list 'org-latex-packages-alist '("" "tikz-cd" t)) 
     (add-to-list 'org-latex-packages-alist '("" "thisisastupidtestfile" t)) 
     (setq org-latex-create-formula-image-program 'dvisvgm) 
     (setq org-format-latex-options 
           (plist-put org-format-latex-options :scale 0.80)))

```

in some org file (`hello.org`), add this latex formula:
`\(\calT \llbracket \tau_H \rrbracket \)`
Invoke `org-latex-preview` (`C-c C-x C-l`).
Open `thisisastupidtestfile.sty` which is situated in the same directory as our `hello.org` file.
Change the definition of: `\newcommand{\calT}{\mathcal{T}}` to `\newcommand{\calT}{\mathcal{K}}` and invoke `org-latex-preview`.

Result: There is no way you can have the image regenerated.

Analysis: the image is associated to the latex input through some hash function (see below). Editing `thisisastupidtestfile.sty` doesn't change the arguments of the hash function, consequently the image isn't regenerated.

I understand org-latex-preview images are associated to latex expression through some hash function:
```
(sha1 (prin1-to-string
       (list org-format-latex-header
	     org-latex-default-packages-alist
	     org-latex-packages-alist
	     org-format-latex-options
	     forbuffer value fg bg)))
```

Now if I edit my custom sty file, the output of the hash function won't change, and therefore the generated image won't change neither.

Note: I haven't been able to compute the return value of the hash function for my latex expression, because I can't figure out what the arguments actually are, specifically `forbuffer`, `fg` and `bg`, but the above reasoning seems sound.
Note: Removing specifically the images looking like the image associated with the latex expression that refuses to be regenerated, using some file manager, and then invoking `org-latex-preview`, does the trick, but it's impractical.

Best,
Chris





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-24 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 17:25 [BUG] org-latex-preview with custom sty file chris
2023-02-24 17:49 ` Timothy
2023-02-24 18:29   ` chris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).