From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id g2g+FfHL5GMxVgAAbAwnHQ (envelope-from ) for ; Thu, 09 Feb 2023 11:33:21 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 8FhDFPHL5GPf1gAAauVa8A (envelope-from ) for ; Thu, 09 Feb 2023 11:33:21 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C5D1C392C1 for ; Thu, 9 Feb 2023 11:33:20 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQ4EO-0007Tq-OJ; Thu, 09 Feb 2023 05:32:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQ4EN-0007Pg-Lj for emacs-orgmode@gnu.org; Thu, 09 Feb 2023 05:32:43 -0500 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQ4EL-0000WQ-Jz for emacs-orgmode@gnu.org; Thu, 09 Feb 2023 05:32:43 -0500 Received: by mail-ej1-x62c.google.com with SMTP id ud5so4982605ejc.4 for ; Thu, 09 Feb 2023 02:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:subject:to:from:message-id:date:from:to:cc :subject:date:message-id:reply-to; bh=HNLBiz8OwPw4nk38DcxIhgTi66bXlo13gJCzsQMQgik=; b=Rx6Nz4XFhGa3TlLBMUq8eQmXG7Gk43JadUNr09zRQqqbS0B8L6Gi51rcx0tHmSlWBO ZIzQpV0GSb4K25VJ9j4VkwcjpVzIV2EURkoL7rJ2MVkdg1cCdPsi1eDHwnYFn6cayt10 cHrwvcgI4wAVG+DYmbwavGdDFFoz/3UTUwX59+OHCKygg/DIyLKUclVTMkq9ANOaUDzX 1KwFJKs8VXv/7uIiR5syRcdvTvzOx0rR3GDcT8ECgNmtvhLcSCIJcxsnfEWulrQgvIRW 2XTVGYAj51hYRCFkdHNCCz+kIKX1Iz8N+FPO3dtLscnG4yqgEXfBjxw+VAhN/i+z47nn HaDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:subject:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HNLBiz8OwPw4nk38DcxIhgTi66bXlo13gJCzsQMQgik=; b=wKfyAGlLaXaRhA/FdBmbPNgvMGDyR+VPec+5MYRqXAXA4b3WanL0BcIJeWUYK29xV0 46kU6928T3fEN5uuGzZ9Mu9g3PZHDJKMt88tB1XnG2qUav2iaaYDSrVDQb0dK1FQIe5l lIDrM23TjFCgcJ+KnCqt7RwR8Tb9URewbIwjcT8xCUAHuAQlYvqKcBUQUtbeoaZJfr7L INzbMjPMWlE1R8yhG9JQEiG3bSkjjgVtyZl/119JS65FM6Fay3bdfQYfXWDQF1Mcilne iVhMyYozFO3nwOr0A5MDbZ1BVKfy2kPb6gv2VmEidPu2pOUGDZzdXTmHxBMLxlgVFwC0 00fg== X-Gm-Message-State: AO0yUKUL9cJFGfyMjVdF6FWfsr7bJoyhgOkrJMwK9EjMRDs4ggNGeFal GF3WcVXAZQn4GXmjPCa+eIIoOXTHjxQ= X-Google-Smtp-Source: AK7set+xR37OcViZDRRnfMy0+3jLQMAXU76ZHyoofN0+JqIhfGKSNjcPv+gTNTYyLWd8PsVl+jpmbQ== X-Received: by 2002:a17:906:6bd4:b0:7b2:757a:1411 with SMTP id t20-20020a1709066bd400b007b2757a1411mr5837966ejs.9.1675938759731; Thu, 09 Feb 2023 02:32:39 -0800 (PST) Received: from paquerette.gmail.com ([2001:861:4284:db70:414b:a383:a4ff:fd35]) by smtp.gmail.com with ESMTPSA id v1-20020a1709064e8100b008779b5c7db6sm694202eju.107.2023.02.09.02.32.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 02:32:39 -0800 (PST) Date: Thu, 09 Feb 2023 11:32:43 +0100 Message-ID: <86sfff5dtg.wl-edouard.debry@gmail.com> From: Edouard Debry To: emacs-orgmode Subject: Re: Creating animated gif from latex src blocks User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-w64-mingw32) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=edouard.debry@gmail.com; helo=mail-ej1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675938801; a=rsa-sha256; cv=none; b=rTwoI9re6ifoCrQISPMaGDK3AiwRjA9barkbzFJcfAF9WdILc9e93oYQhYNXFbX8H6Rf46 sChffuIAGGgVseASXPN/qUsnEvNo9xfgpRM+aMey4N2S4x7DJGwWeQ59yrep+eWDz7XyB7 YA2HPylmzgVBdxnjME7dWjr/rxn2iqiXaGsQXowY5Qgd81k+q4NO6YjnoiSAEiostCWS1h Wry0UtzIPq1004k93aiJqK3lZCycTaTN6k2rF23FtUn48WGbCUrbU74Kn5rg2W4m0jLoOQ 0XNBoO06ThcnolrxUKkCARqul/7n0RMG+eHnYZFwPatWT/Ll1Otul9ubGgn9jg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Rx6Nz4XF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675938801; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=HNLBiz8OwPw4nk38DcxIhgTi66bXlo13gJCzsQMQgik=; b=o4b1CiKZkdlMgHMmN9cQbw1r1gVUQPcb3Za/HpRNpUAuEJlYUwfKts1YDqu81h9IY4w0zu C0/nuUzis2u5KtzVbQrsE+55FKF148Cpf0jnnw5DvVBhJghf/nYSRC6SB8T0mrcGuw7dbQ QA0doKJHXdyjU0P2rrKPvT/M24JQ8BiCPaly89IfCX5e43Qt1Rx/5buY/nF6+0N8hvqiTW T1rmP6HglmZ2JL+mRfhnjKArOpbq7WL9yC4pvHfHdYx5T9FGtrl2BHFw7vR3rJf4su/aW2 258k11V6FJVMfnBr+Uv1HotREWbUGdz+i3NxgfolLFyF/+seWQwd18q/q99Whw== X-Spam-Score: -5.30 X-Migadu-Queue-Id: C5D1C392C1 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Rx6Nz4XF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.30 X-TUID: lKizjdgx/zLr Hi, In reply to an old thread initiated, here is how I get animated pictures from latex src blocks. <=========================== GIF image ===============================> #+NAME: before-make-gif #+begin_src elisp :lexical no :results none (setq org-format-latex-header "\\documentclass[tikz]{standalone}") (setq org-latex-default-packages-alist nil) (setq org-latex-packages-alist nil) #+end_src #+NAME: after-make-gif #+begin_src elisp :lexical no :results none (custom-reevaluate-setting 'org-format-latex-header) (custom-reevaluate-setting 'org-latex-packages-alist) (custom-reevaluate-setting 'org-latex-default-packages-alist) #+end_src #+NAME: make-gif #+header: :file test1.gif #+header: :exports results #+header: :results output silent graphics file #+header: :imagemagick yes #+header: :iminoptions -density 600 -delay 8 -loop 0 -background white -alpha remove #+header: :headers '("\\usepackage{tikz}" "") #+begin_src latex \foreach \angle in {0,10,...,360} % { \begin{tikzpicture} % fill circle and plot \fill[blue!50] (-1,0) arc (0:\angle:1) -- (-2,0) -- cycle; \fill[blue!50] plot[smooth,domain=0:\angle] (pi/180*\x,{sin(\x)}) |- (0,0); % draw connection \draw (-2,0) +(\angle:1) circle (2pt) -- (pi/180*\angle,{sin(\angle)}) circle (2pt); % draw axes an ticks \draw (-3.5,0) -- (7,0); \foreach \deg in {90, 180, 270, 360} \draw (pi/180*\deg,2pt) -- (pi/180*\deg,-2pt) node[below] {$\deg^\circ$}; \draw (0,-1.2) -- (0,1.2); \foreach \y in {-1,-0.5,0.5,1} \draw (2pt,\y) -- (-2pt,\y) node[left] {$\y$}; % draw plot and circle outline \draw plot[smooth,domain=0:360] (pi/180*\x,{sin(\x)}); \draw (-2,0) circle (1); \end{tikzpicture} } #+end_src #+ATTR_ORG: :width 1500 :height 600 [[file:test1.gif]] <=========================== GIF image ===============================> <=========================== SVG image ===============================> #+NAME: before-make-svg #+begin_src elisp :lexical no :results none (setq org-format-latex-header "\\documentclass[dvisvgm]{standalone}") (setq org-latex-default-packages-alist nil) (setq org-latex-packages-alist nil) #+end_src #+NAME: after-make-svg #+begin_src elisp :lexical no :results none (custom-reevaluate-setting 'org-format-latex-header) (custom-reevaluate-setting 'org-latex-packages-alist) (custom-reevaluate-setting 'org-latex-default-packages-alist) #+end_src #+NAME: make-svg #+header: :file test1.svg #+header: :exports results #+header: :results output silent graphics file #+header: :headers '("\\usepackage{animate}" "\\usepackage{tikz}" "\\pgfmathsetmacro{\\pendulumswing}{40}" "\\pgfmathsetmacro{\\pendulumlength}{5}") #+begin_src latex \begin{animateinline}[controls, palindrome]{45} \multiframe{45}{rt=0+4}{% \begin{tikzpicture}[line width=1pt] \draw[dashed] (0:0) -- (90:{-\pendulumlength}) coordinate (o); \draw[dashed] ({90-\pendulumswing}:{-\pendulumlength}) coordinate (a) arc[start angle={90-\pendulumswing}, end angle={90+\pendulumswing}, radius={-\pendulumlength}] coordinate (b); \draw[dashed, red] (a) -- (a |- o) coordinate (c) node[below] {$-x_m$}; \draw[dashed, red] (b) -- (b |- o) coordinate (d) node[below] {$x_m$}; \draw[-stealth, red] ([xshift=-1cm]c) -- ([xshift=1cm]d); % variable \rt goes from 0 to 180 % cos(\rt) returns a value between -1 and 1 following a (co)sine curve \pgfmathsetmacro{\pendulumangle}{cos(\rt)*\pendulumswing} \draw (0:0) -- ({90+\pendulumangle}:{-\pendulumlength}) node[circle, fill=blue, text=white] {$\mathbf{m}$}; \end{tikzpicture}% }% \end{animateinline} #+end_src #+ATTR_ORG: :width 1500 :height 600 [[file:test1.svg]] <=========================== SVG image ===============================> The GIF generation first goes through generating a PDF file and then, converts it afterwards to gif with ImageMagick. It only uses "tikz" latex package. The SVG generation uses "tikz" and "animate" latex packages. This latter is initiated with "dvisvgm" and therefore, the src block is configured to produce a svg file ("dvisvgm" again under the hood). The GIF image shows up correctly animated in emacs, either as a plain file or as a link in orgmode (org-inline-animate). The SVG file is statically well displayed in emacs, but not animated. As far as I understand the "animate" package uses javascript under the hood and indeed, the SVG file is correctly animated in (e.g.) the chromium browser. That is to note that for correct image generation, I had to tweak 'org-format-latex-header, , 'org-latex-packages-alist and 'org-latex-default-packages-alist orgmode variables. Setting nil for two latters is probably a bit too harsh, but I did not have enough time to figure out which package was causing problems. So, as you may have guessed, before evaluating the latex block, I evaluate the first elisp block and after, the second elisp block's evaluation reverts orgmode variables to their previous settings. This is a bit annoying, I wonder if there is a way to automatically evaluate both elisp blocks when running the latex block, one before and one after. I know that some blocks can be called within other code blocks but obviously, with the same language. Perhaps the "#+CALL:" syntax can call several code blocks ? #+CALL : before-gif() make-gif() after-gif() Let me know if you find a lighter way to generate animated images from src code blocks. Hope this helps Regards Edouard Debry