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

* Re: [BUG] org-latex-preview with custom sty file
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy @ 2023-02-24 17:49 UTC (permalink / raw)
  To: chris; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

Hi Chris,

> 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.

Yea, `org-format-latex' is a bit of a nightmare. I’ve got a WIP overhaul of the
entire LaTeX preview system which is currently 95% of the way done. The new
system will still not notice changes in package source files, but it will be
easy to clear the cache and regenerate.

All the best,
Timothy

-- 
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/tec>.

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

* Re: [BUG] org-latex-preview with custom sty file
  2023-02-24 17:49 ` Timothy
@ 2023-02-24 18:29   ` chris
  0 siblings, 0 replies; 3+ messages in thread
From: chris @ 2023-02-24 18:29 UTC (permalink / raw)
  To: emacs-orgmode

On Friday, 24 February 2023 18:49:10 CET Timothy wrote:
> Hi Chris,
> 
> > 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.
> 
> Yea, `org-format-latex' is a bit of a nightmare. I’ve got a WIP overhaul of the
> entire LaTeX preview system which is currently 95% of the way done. The new
> system will still not notice changes in package source files, but it will be
> easy to clear the cache and regenerate.

There is that, which is supposed to be included in org-mode 9.7:
https://github.com/karthink/org-preview?

I suppose for image regeneration it needs user manual intervention, otherwise it's the same to do `rm ltximg/*`.

If I were able to compute the output of the hash function I could have decided which image to selectively remove.

> 
> All the best,
> Timothy
> 
> 






^ 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).