emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pre-PATCH] Overhaul of the LaTeX preview system


From: Rudolf Adamkovič
Subject: Re: [Pre-PATCH] Overhaul of the LaTeX preview system
Date: Sat, 03 Jun 2023 11:00:13 +0200

Timothy <orgmode@tec.tecosaur.net> writes:

> Thanks for testing the branch :)

Thank you for your reply.

> We’re thinking of adding `--exact-bbox' to the default `dvisvgm'
> flags, which it seems has a good chance of resolving this. It was
> originally swapped for `--bbox=preview' (when using `dvisvgm' to get
> dimension info), but now we do this via the LaTeX compilation stdout,
> and so we can go back to `--exact-bbox'.

This would be great.  Please!

> I tried this example on my computer, and it worked flawlessly (see
> <https://0x0.st/Hq7Z.png>). If you could give me a stacktrace, that
> might help.

OMG! OMG! OMG!  So, this new system not only fixes the baseline problem,
making LaTeX actually usable in HTML exports, but it also makes TikZ
work?!  No more fiddling with LaTeX Org Babel?  No more per-image
scaling headaches?  Now, that is INCREDIBLE!

Below, I re-create a MWE end-to-end.

******** CONFIGURATION ********

- OS:

macOS 13.3.1 (22E261)
ARM/M1 architecture
native compilation

- Org mode:

https://git.tecosaur.net/tec/org-mode.git
branch: origin/dev
commit: a92c62287

- Emacs:

official repository
branch: origin/master
commit: dc3b3548b7c
compilation flags:

make extraclean && ./autogen.sh && ./configure --with-json --with-xwidgets 
--with-native-compilation=aot && make -j 8 bootstrap && make install

- No '.emacs.d'.

- In '.emacs', the following:

;; Make Emacs native compilation work on Apple/macOS jails.
(when (eq window-system 'ns)
  (setenv "LIBRARY_PATH"
            (string-join
             '("/opt/homebrew/opt/gcc/lib/gcc/13"
               "/opt/homebrew/opt/libgccjit/lib/gcc/13"
               "/opt/homebrew/opt/gcc/lib/gcc/13/gcc/aarch64-apple-darwin22/13")
             ":")))

;; Make Emacs find binaries on Apple/macOS jails.
(when (eq window-system 'ns)
  (defun shell-get-environment-variable+ (variable)
    "Return the value of VARIABLE from login shell."
    (shell-command-to-string
     (format "$SHELL --login -c 'echo -n $%s'" variable)))

  ;; Set the path to executables.
  (let* ((path "PATH")
         (path-value (shell-get-environment-variable+ path)))
    (setenv path path-value)
    (setq exec-path (split-string path-value path-separator)))

  ;; Set the locale.
  (let* ((variable "LC_ALL")
         (variable-value (shell-get-environment-variable+ variable)))
    (setenv variable variable-value)))

;; Load the new Org.
(add-to-list 'load-path "~/src/org-mode-tecosaur/lisp")

;; Make Org work without the arrow keys.
(setq-default org-use-extra-keys t)

******** TEST DOCUMENT ********

Saved in '~/test.org':

#+TITLE: Hello there
#+OPTIONS: tex:dvisvgm
#+LATEX_HEADER: \usepackage{tikz}

\begin{equation*}
1 + 1 = 2
\end{equation*}

\begin{tikzpicture}
  \filldraw (0, 0) circle[radius = 1cm];
\end{tikzpicture}

******** REPRODUCTION STEPS ********

1. Open the test document.
2. Type C-c C-x C-l inside of the 'equation' environment.
3. See the preview, to verify basic LaTeX previews work.
4. Type C-c C-x C-l inside of the 'tikzpicture' environment.

EXPECTED:

See the expected TikZ preview, a circle.

ACTUAL:

- No TikZ preview.
- "Wrong type argument: stringp, nil" in the echo area.

******** TRACE ********

The steps:

1. Type M-x toggle-debug-on-error RET.
2. Repeat the reproduction steps.
3. Expand all '...' in the trace.
4. Save the trace.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-exists-p(nil)
  org-latex-preview--svg-make-fg-currentColor((:string 
"\\color[rgb]{0,0,0.00392157}\\setcounter{equation}{0}%\n\\begin{tikzpicture}\n 
 \\filldraw (0, 0) circle[radius = 1cm];\n\\end{tikzpicture}\n" :overlay 
#<overlay from 125 to 203 in test.org> :key 
"6f292c841630b664deb0178c18bdfc5ceb532272" :depth 0.04918392937239927 :height 
5.714304984431469 :width 36.21927976341847 :errors nil :path nil :error "Image 
file not produced."))
  org-latex-preview--dvisvgm-filter(#<process org-async-dvisvgm-4> "processing 
page 1\n  WARNING: 50 PostScript specials ignored. The resulting SVG might look 
wrong.\n  page is empty\n  graphic size: 0pt x 0pt (0mm x 0mm)\n  output 
written to 
/var/folders/ky/8r5j3qz55hb94lpg1jr9vl1c0000gn/T/org-tex-4tn7FE-000000001.svg\n1
 of 1 page converted in 0.153852 seconds\n" (:latex-processor "pdflatex" 
:latex-header "% Intended LaTeX compiler: 
pdflatex\n\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n%
 Package hyperref omitted\n\\usepackage{xcolor}\n\n\\usepackage{tikz}\n\n\n% 
Generated preamble omitted for 
snippets.\n\n\n\\makeatletter\n\\renewcommand{\\theequation}{\\(\\diamond\\)\\ifnum\\value{equation}>1%\n\\,+\\,\\@arabic{\\numexpr\\value{equation}-1\\relax}\\fi}\n\\makeatother"
 :programs ("latex" "dvisvgm") :description "dvi > svg" :message "you need to 
install the programs: latex and dvisvgm." :image-input-type "dvi" 
:image-output-type "svg" :latex-compiler ("%l -interaction nonstopmode 
-output-directory %o %f") :latex-precompiler ("%l -output-directory %o -ini 
-jobname=%b \"&%L\" mylatexformat.ltx %f") :image-converter ("dvisvgm --page=1- 
--optimize --clipjoin --relative --no-fonts --bbox=preview -o %B-%%9p.svg %f") 
:processor dvisvgm :fragments ((:string 
"\\color[rgb]{0,0,0.00392157}\\setcounter{equation}{0}%\n\\begin{tikzpicture}\n 
 \\filldraw (0, 0) circle[radius = 1cm];\n\\end{tikzpicture}\n" :overlay 
#<overlay from 125 to 203 in test.org> :key 
"6f292c841630b664deb0178c18bdfc5ceb532272" :depth 0.04918392937239927 :height 
5.714304984431469 :width 36.21927976341847 :errors nil :path nil :error "Image 
file not produced.")) :org-buffer #<buffer test.org> :texfile 
"/Users/salutis/org-tex-4tn7FE.tex" :place-preview-p t :fontsize 10 :tightpage 
(-32891 -32891 32891 32891)))
  org-async--filter(#<process org-async-dvisvgm-4> "processing page 1\n  
WARNING: 50 PostScript specials ignored. The resulting SVG might look wrong.\n  
page is empty\n  graphic size: 0pt x 0pt (0mm x 0mm)\n  output written to 
/var/folders/ky/8r5j3qz55hb94lpg1jr9vl1c0000gn/T/org-tex-4tn7FE-000000001.svg\n1
 of 1 page converted in 0.153852 seconds\n")

Rudy
-- 
"Mathematics takes us still further from what is human into the region
of absolute necessity, to which not only the actual world, but every
possible world, must conform."
-- Bertrand Russell, 1902

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



reply via email to

[Prev in Thread] Current Thread [Next in Thread]