all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Akira Kyle <akira@akirakyle.com>
Cc: emacs-orgmode@gnu.org,  reza@housseini.me
Subject: Re: svg file from tikz picture
Date: Sun, 25 Sep 2022 15:52:20 +0800	[thread overview]
Message-ID: <87o7v3sxfv.fsf@localhost> (raw)
In-Reply-To: <87czbmg6xi.fsf@akirakyle.com>

Akira Kyle <akira@akirakyle.com> writes:

> I've been using the attached patch for the last few years and I've meaning to send it here/start a discussion about ob-latex.el since I used it pretty much daily to write tikz figures in org mode. So I'm glad to see this discussion has been started!
>
> I've found it to be incredibly productive to use babel to develop tikz diagrams as I can make come changes and quickly `org-ctrl-c-ctrl-c` to render them in the same buffer.
>
> I think when I made this patch I had been caught by some of the quirks of the svg export. For example, sometimes I would have some latex equation which I use ~org-latex-preview~ on as I was writing it, but then it would fail to render as mathjax upon html export since I would use some latex package that isn't available under mathjax. So by using ob-latex I could easily fix this by using the ~:file .svg~ header and get a nice html export. However due to the different way of assembling the ~.tex~ file sometimes ~org-latex-preview~ would work but ob-latex wouldn't. I think my use case may be fairly common and so I think ob-latex really should be updated so svg uses the ~org-latex-preview~ code. o

Thanks a lot for the patch!
I am not very familiar with the code here, but I will try to cross-check
things as much as possible as an initial feedback.

> Also I think the ~.tikz~ extension doesn't really make any sense since one really can but arbitrary tex code in such a block, and I think that's why I renamed it in my patch. However I'm now realizing that this evaluation method probably doesn't make much since `:tangle` will already do this, with the added benefit of handling noweb references correctly. So perhaps this should be removed and document using tangling in lieu of ~:file *.tikz~?

This sounds reasonable, but we must not remove it just yet. Instead, we
need to support .tex extension _and_ .tikz extension as backwards
compatibility. For .tikz extension we may also display a warning that it
is obsolete.

> -(defcustom org-babel-latex-htlatex-packages
> -  '("[usenames]{color}" "{tikz}" "{color}" "{listings}" "{amsmath}")
> -  "Packages to use for htlatex export."
> -  :group 'org-babel
> -  :type '(repeat (string)))

Removing this defcustom will be a regression. Maybe we can instead
append it to org-latex-packages-alist? Note that {color} and {tikz} are
not loaded by default in `org-format-latex-header'.

> +	     (org-format-latex-header
> +	      (concat org-format-latex-header
> +		      (mapconcat #'identity (cdr (assq :headers params)) "\n")
> +		      (if fit "\n\\usepackage[active, tightpage]{preview}\n" "")

(concat "a" nil "b") is perfectly acceptable. There is no need to supply
empty strings as `concat' arguments.
Can simply use (when fit ...)

> +(defun org-babel-latex-format-tex (tex-file body)
> +  "Generate a temporary tex file from execute params."
> +  (with-temp-file tex-file
> +    (insert
> +     (org-latex-make-preamble
> +      (org-export-get-environment (org-export-get-backend 'latex))
> +      org-format-latex-header)
> +     (concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))

I note that `org-export-get-environment' will be ran inside a temporary
file. It means that Org buffer LaTeX export settings for the source
buffer will not affect the return value. I assume that it is
intentional. If so, it is worth adding a comment about it into the code.

>  
> -(defun org-babel-latex-tex-to-pdf (file)
> -  "Generate a pdf file according to the contents FILE."
> -  (require 'ox-latex)
> -  (org-latex-compile file))
> -

This is removing a non-private function. Even though this function is
nothing but trivial, we still cannot remove it without notice.
The function should be moved to org-compat.el and marked obsolete.

Finally, please note that we follow certain commit message standards in
Org mode. See https://orgmode.org/worg/org-contribute.html#commit-messages

-- 
Ihor Radchenko,
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/yantar92


  reply	other threads:[~2022-09-25  7:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3bc47afb-0bac-f6e8-1097-13dcb6f2be1f@housseini.me>
2022-08-15 18:50 ` svg file from tikz picture reza
2022-08-16  9:42   ` Ihor Radchenko
     [not found]     ` <964a4117-ef6c-8d41-a25d-00e61c0c93d8@housseini.me>
2022-08-16 10:00       ` reza
2022-08-16 10:13         ` Ihor Radchenko
     [not found]           ` <0931497c-9075-c214-c7f2-6507340a6d74@housseini.me>
2022-08-16 10:19             ` reza
2022-08-16 10:31               ` Ihor Radchenko
     [not found]                 ` <6daeb56b-163c-f862-5866-da624b43edd9@housseini.me>
2022-08-16 11:06                   ` reza
2022-08-16 11:22                     ` Ihor Radchenko
     [not found]                       ` <7dcd1348-6faf-8464-38b5-8efac7c69250@housseini.me>
2022-08-16 11:25                         ` reza
     [not found]                           ` <be3e5412-37ff-c1c7-7a27-3793d72842d4@housseini.me>
2022-09-20  9:55                             ` reza
2022-09-20 20:53                               ` Edouard Debry
2022-09-21  9:32                               ` Ihor Radchenko
2022-09-23  2:28                                 ` Akira Kyle
2022-09-25  7:52                                   ` Ihor Radchenko [this message]
2022-11-14  5:52                                     ` Ihor Radchenko
2023-03-24 23:22                                       ` Akira Kyle
2023-03-25 18:13                                         ` Ihor Radchenko
2023-03-25 18:14                                           ` Akira Kyle
2023-03-25 18:25                                             ` Ihor Radchenko
2023-04-19  9:57                                               ` Bastien Guerry
2023-08-05  9:34                                                 ` Ihor Radchenko
2023-08-05 17:29                                                   ` Bastien Guerry
2023-08-05 18:38                                                     ` Akira Kyle
2023-08-06  5:37                                                       ` Bastien Guerry
2023-08-06  5:40                                                       ` Bastien Guerry
2023-10-19  9:51                                                       ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7v3sxfv.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=akira@akirakyle.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=reza@housseini.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.