emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Creating animated gif from latex src blocks
@ 2022-06-17 13:21 DEBRY.Edouard
  2022-06-17 13:43 ` Fraga, Eric
  0 siblings, 1 reply; 6+ messages in thread
From: DEBRY.Edouard @ 2022-06-17 13:21 UTC (permalink / raw)
  To: Emacs-orgmode


Hello,

I would like to create an animated gif for a latex src block.

Here to fix ideas such a block :

<====================================================================================>
#+header: :file test4.gif
#+header: :exports results
#+header: :results output silent graphics file
#+header: :imagemagick yes :iminoptions -density 600 -delay 8 -loop 0 -background white -alpha remove
#+header: :fit yes :noweb yes :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
<====================================================================================>

grabbed here :
https://tex.stackexchange.com/questions/291627/draw-an-animated-gif-of-trigonometry-function

When hitting [C-c C-c], it does produce a gif, but which cannot be
animated.

I downloaded another animated gif on internet which works properly
within emacs, so the issue comes most probably from the latex to pdf
generation.

I noticed that the latex header used is

<==============================================================>
\documentclass{article}
\usepackage[usenames]{color}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\pagestyle{empty}             % do not remove
% The settings below are copied from fullpage.sty
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-3cm}
\setlength{\oddsidemargin}{1.5cm}
\addtolength{\oddsidemargin}{-2.54cm}
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\addtolength{\textheight}{-3cm}
\setlength{\topmargin}{1.5cm}
\addtolength{\topmargin}{-2.54cm}
\usepackage[active, tightpage]{preview}
<==============================================================>

which is different from the latex header used in tex.stackexchange page
:
<========================================>
\documentclass[tikz]{standalone}
\usepackage{tikz}
<========================================>

I replaced the default header provided by emacs with this very one and
it worked. Is it possible to modify the latex header depending on the
export image format ?

Regards

___________________________________________________________________________________________________________________________________

This email and any attachments are confidential to the intended recipient and may also be privileged.
If you are not the intended recipient please delete it from your system and notify the sender. 
You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
 

Ce courriel et ses pieces-jointes sont envoyes de maniere confidentielle et doivent etre traites avec attention.
Si vous n'etes pas le destinataire, merci de le detruire et d'en informer son auteur. 
Vous ne devez pas copier, utiliser, reveler ou diffuser son contenu a quiconque.



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

* Re: Creating animated gif from latex src blocks
  2022-06-17 13:21 Creating animated gif from latex src blocks DEBRY.Edouard
@ 2022-06-17 13:43 ` Fraga, Eric
  2022-06-17 22:26   ` Edouard Debry
  0 siblings, 1 reply; 6+ messages in thread
From: Fraga, Eric @ 2022-06-17 13:43 UTC (permalink / raw)
  To: DEBRY.Edouard; +Cc: Emacs-orgmode

Check out the animate LaTeX package.  I don't believe you can create
such the actual animation from tikz itself.

-- 
: Eric S Fraga, with org release_9.5.4-535-ged6f8d in Emacs 29.0.50

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

* Re: Creating animated gif from latex src blocks
  2022-06-17 13:43 ` Fraga, Eric
@ 2022-06-17 22:26   ` Edouard Debry
  2022-06-17 23:04     ` Ihor Radchenko
  2022-06-18  9:06     ` Fraga, Eric
  0 siblings, 2 replies; 6+ messages in thread
From: Edouard Debry @ 2022-06-17 22:26 UTC (permalink / raw)
  To: Org Mode List


As a matter of fact, you can, but I will check out the latex package you mentioned

"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:

> Check out the animate LaTeX package.  I don't believe you can create
> such the actual animation from tikz itself.


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

* Re: Creating animated gif from latex src blocks
  2022-06-17 22:26   ` Edouard Debry
@ 2022-06-17 23:04     ` Ihor Radchenko
  2022-06-18  9:06     ` Fraga, Eric
  1 sibling, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2022-06-17 23:04 UTC (permalink / raw)
  To: Edouard Debry; +Cc: Org Mode List

Edouard Debry <edouard.debry@gmail.com> writes:

> As a matter of fact, you can, but I will check out the latex package you mentioned
>
> "Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
>
>> Check out the animate LaTeX package.  I don't believe you can create
>> such the actual animation from tikz itself.

FYI, animate package can work, but it is not guaranteed that the results
can be actually viewed by anything other than Adobe Acrobat.

Best,
Ihor


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

* Re: Creating animated gif from latex src blocks
  2022-06-17 22:26   ` Edouard Debry
  2022-06-17 23:04     ` Ihor Radchenko
@ 2022-06-18  9:06     ` Fraga, Eric
  2022-06-19 14:03       ` Edouard Debry
  1 sibling, 1 reply; 6+ messages in thread
From: Fraga, Eric @ 2022-06-18  9:06 UTC (permalink / raw)
  To: Edouard Debry; +Cc: Org Mode List

On Saturday, 18 Jun 2022 at 00:26, Edouard Debry wrote:
> As a matter of fact, you can, but I will check out the latex package you mentioned
>
> "Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
>
>> Check out the animate LaTeX package.  I don't believe you can create
>> such the actual animation from tikz itself.

Clarification: I believe(d) that you cannot generate an animated GIF;
animation is possible, of course.  But if you can generate an animated
GIF directly from tikz, please let me know how as it would be useful in
some cases.

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.5.4-564-g811dea in Emacs 29.0.50

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

* Re: Creating animated gif from latex src blocks
  2022-06-18  9:06     ` Fraga, Eric
@ 2022-06-19 14:03       ` Edouard Debry
  0 siblings, 0 replies; 6+ messages in thread
From: Edouard Debry @ 2022-06-19 14:03 UTC (permalink / raw)
  To: Org Mode List


Here is what I am able to do :
- write a latex src block with several tikz blocks inside (as described
  in the tex.stackexchange link)
- export in a gif with pdf+imagmagick
- open the gif in emacs and start the animation
- insert the gif into the org file and start animation

But there is a trick for this to work, the default latex header is
"\\documentclass{article} ...", which fails but, replacing it
by "\\documentclass[tikz]{standalone} ..." succeeds.

Regards


"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:

> On Saturday, 18 Jun 2022 at 00:26, Edouard Debry wrote:
>> As a matter of fact, you can, but I will check out the latex package you mentioned
>>
>> "Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
>>
>>> Check out the animate LaTeX package.  I don't believe you can create
>>> such the actual animation from tikz itself.
>
> Clarification: I believe(d) that you cannot generate an animated GIF;
> animation is possible, of course.  But if you can generate an animated
> GIF directly from tikz, please let me know how as it would be useful in
> some cases.
>
> Thank you,
> eric


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

end of thread, other threads:[~2022-06-19 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 13:21 Creating animated gif from latex src blocks DEBRY.Edouard
2022-06-17 13:43 ` Fraga, Eric
2022-06-17 22:26   ` Edouard Debry
2022-06-17 23:04     ` Ihor Radchenko
2022-06-18  9:06     ` Fraga, Eric
2022-06-19 14:03       ` Edouard Debry

Code repositories for project(s) associated with this 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).