How do we compile and visualize the animations of TikZ 3.1?












16















I copied and pasted the example from page 221 of manual 3.1 and tried to compile it with Texmaker.



documentclass[dvisvgm]{standalone} 
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


The .pdf file result produced does is this one:



click



The result given as an example on the manual is this one:



example-manual



I opened the .pdf file produced on Chrome, Opera and Firefox, I don't have any animation.





  1. How should I compile the animations of TikZ 3.1?




    • on the command line

    • with Texmaker

    • with TeXstudio




  2. And how do we open these files?




    • Is it possible to view them with a PDF reader?

    • Is it necessary to use a web browser?












share|improve this question

























  • You can't use the dvisvgm driver when compiling to PDF. I'm quite surprised that you even get a usable PDF out of that. Also you have to add tikzset{make snapshot if necessary}, to force a snapshot for the PDF.

    – Henri Menke
    2 days ago













  • @HenriMenke : Because the drawing specials in the DVI are still PostScript. dvisvgm is linked against Ghostscript's libgs.so library.

    – AlexG
    2 days ago













  • @AlexG OP is not using dvisvgm but compiling to PDF. So you end up with dvisvgm specials in the PDF file which is likely to corrupt the file.

    – Henri Menke
    2 days ago











  • @HenriMenke One can even embed EPS files with includegraphics without any driver option. dvisvgm delegates PSFile special to libgs.

    – AlexG
    2 days ago






  • 1





    dvisvgm specials are mostly animation-related and simply ignored during conversion to PDF.

    – AlexG
    2 days ago
















16















I copied and pasted the example from page 221 of manual 3.1 and tried to compile it with Texmaker.



documentclass[dvisvgm]{standalone} 
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


The .pdf file result produced does is this one:



click



The result given as an example on the manual is this one:



example-manual



I opened the .pdf file produced on Chrome, Opera and Firefox, I don't have any animation.





  1. How should I compile the animations of TikZ 3.1?




    • on the command line

    • with Texmaker

    • with TeXstudio




  2. And how do we open these files?




    • Is it possible to view them with a PDF reader?

    • Is it necessary to use a web browser?












share|improve this question

























  • You can't use the dvisvgm driver when compiling to PDF. I'm quite surprised that you even get a usable PDF out of that. Also you have to add tikzset{make snapshot if necessary}, to force a snapshot for the PDF.

    – Henri Menke
    2 days ago













  • @HenriMenke : Because the drawing specials in the DVI are still PostScript. dvisvgm is linked against Ghostscript's libgs.so library.

    – AlexG
    2 days ago













  • @AlexG OP is not using dvisvgm but compiling to PDF. So you end up with dvisvgm specials in the PDF file which is likely to corrupt the file.

    – Henri Menke
    2 days ago











  • @HenriMenke One can even embed EPS files with includegraphics without any driver option. dvisvgm delegates PSFile special to libgs.

    – AlexG
    2 days ago






  • 1





    dvisvgm specials are mostly animation-related and simply ignored during conversion to PDF.

    – AlexG
    2 days ago














16












16








16


5






I copied and pasted the example from page 221 of manual 3.1 and tried to compile it with Texmaker.



documentclass[dvisvgm]{standalone} 
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


The .pdf file result produced does is this one:



click



The result given as an example on the manual is this one:



example-manual



I opened the .pdf file produced on Chrome, Opera and Firefox, I don't have any animation.





  1. How should I compile the animations of TikZ 3.1?




    • on the command line

    • with Texmaker

    • with TeXstudio




  2. And how do we open these files?




    • Is it possible to view them with a PDF reader?

    • Is it necessary to use a web browser?












share|improve this question
















I copied and pasted the example from page 221 of manual 3.1 and tried to compile it with Texmaker.



documentclass[dvisvgm]{standalone} 
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


The .pdf file result produced does is this one:



click



The result given as an example on the manual is this one:



example-manual



I opened the .pdf file produced on Chrome, Opera and Firefox, I don't have any animation.





  1. How should I compile the animations of TikZ 3.1?




    • on the command line

    • with Texmaker

    • with TeXstudio




  2. And how do we open these files?




    • Is it possible to view them with a PDF reader?

    • Is it necessary to use a web browser?









tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







AndréC

















asked Jan 9 at 17:50









AndréCAndréC

8,35411445




8,35411445













  • You can't use the dvisvgm driver when compiling to PDF. I'm quite surprised that you even get a usable PDF out of that. Also you have to add tikzset{make snapshot if necessary}, to force a snapshot for the PDF.

    – Henri Menke
    2 days ago













  • @HenriMenke : Because the drawing specials in the DVI are still PostScript. dvisvgm is linked against Ghostscript's libgs.so library.

    – AlexG
    2 days ago













  • @AlexG OP is not using dvisvgm but compiling to PDF. So you end up with dvisvgm specials in the PDF file which is likely to corrupt the file.

    – Henri Menke
    2 days ago











  • @HenriMenke One can even embed EPS files with includegraphics without any driver option. dvisvgm delegates PSFile special to libgs.

    – AlexG
    2 days ago






  • 1





    dvisvgm specials are mostly animation-related and simply ignored during conversion to PDF.

    – AlexG
    2 days ago



















  • You can't use the dvisvgm driver when compiling to PDF. I'm quite surprised that you even get a usable PDF out of that. Also you have to add tikzset{make snapshot if necessary}, to force a snapshot for the PDF.

    – Henri Menke
    2 days ago













  • @HenriMenke : Because the drawing specials in the DVI are still PostScript. dvisvgm is linked against Ghostscript's libgs.so library.

    – AlexG
    2 days ago













  • @AlexG OP is not using dvisvgm but compiling to PDF. So you end up with dvisvgm specials in the PDF file which is likely to corrupt the file.

    – Henri Menke
    2 days ago











  • @HenriMenke One can even embed EPS files with includegraphics without any driver option. dvisvgm delegates PSFile special to libgs.

    – AlexG
    2 days ago






  • 1





    dvisvgm specials are mostly animation-related and simply ignored during conversion to PDF.

    – AlexG
    2 days ago

















You can't use the dvisvgm driver when compiling to PDF. I'm quite surprised that you even get a usable PDF out of that. Also you have to add tikzset{make snapshot if necessary}, to force a snapshot for the PDF.

– Henri Menke
2 days ago







You can't use the dvisvgm driver when compiling to PDF. I'm quite surprised that you even get a usable PDF out of that. Also you have to add tikzset{make snapshot if necessary}, to force a snapshot for the PDF.

– Henri Menke
2 days ago















@HenriMenke : Because the drawing specials in the DVI are still PostScript. dvisvgm is linked against Ghostscript's libgs.so library.

– AlexG
2 days ago







@HenriMenke : Because the drawing specials in the DVI are still PostScript. dvisvgm is linked against Ghostscript's libgs.so library.

– AlexG
2 days ago















@AlexG OP is not using dvisvgm but compiling to PDF. So you end up with dvisvgm specials in the PDF file which is likely to corrupt the file.

– Henri Menke
2 days ago





@AlexG OP is not using dvisvgm but compiling to PDF. So you end up with dvisvgm specials in the PDF file which is likely to corrupt the file.

– Henri Menke
2 days ago













@HenriMenke One can even embed EPS files with includegraphics without any driver option. dvisvgm delegates PSFile special to libgs.

– AlexG
2 days ago





@HenriMenke One can even embed EPS files with includegraphics without any driver option. dvisvgm delegates PSFile special to libgs.

– AlexG
2 days ago




1




1





dvisvgm specials are mostly animation-related and simply ignored during conversion to PDF.

– AlexG
2 days ago





dvisvgm specials are mostly animation-related and simply ignored during conversion to PDF.

– AlexG
2 days ago










4 Answers
4






active

oldest

votes


















18














Animations works only with the SVG format. So you should compile your example at first with latex (not pdflatex). Then you should run dvisvgm file which will show something like this in a command line



C:UsersXXXDocumentstests>dvisvgm test-utf8
pre-processing DVI file (format version 2)
processing page 1
graphic size: 66.670012pt x 51.11758pt (23.431829mm x 17.965775mm)
output written to test-utf8.svg
1 of 1 page converted in 1.64 seconds


You will then find a .svg-file in your folder which you can open in a browser or some other application that understand svg.



You can't
see the animations in pdf, but you can take snapshots:




  1. remove the dvisvgm option


  2. then run this with pdflatex





documentclass{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}
foreach t in {0.5, 1, 1.5, 2}
{
tikz[make snapshot of=t]
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};}

end{document}


enter image description here






share|improve this answer


























  • Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

    – AndréC
    2 days ago






  • 2





    @UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

    – berkus
    2 days ago






  • 1





    @AndréC sorry, typo. I meant "you can't see ...".

    – Ulrike Fischer
    2 days ago






  • 1





    The snapshots are for a pdf. Don't mix up the two methods.

    – Ulrike Fischer
    2 days ago






  • 1





    @berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

    – AlexG
    2 days ago



















13














There are some dvisvgm command line options that are not mentioned in the TikZ manual, but which should generally be used.





Font format: --font-format=woff



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[varwidth]{standalone}
usepackage{amsmath}

begin{document}
Hello World!
begin{equation*}
int_0^1 2x dx = 1
end{equation*}
end{document}


Compile with:



latex texsx-469409-a
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409-a


The default font format that dvisvgm embeds in the SVG output is not correctly interpreted by most WEB browsers. Instead, browsers use some replacement font, e. g. Times. Also, mathematical symbols may be incorrectly displayed:





Therefore, always add option --font-format=woff!!! The default font format may change in future dvisvgm versions.







Improved bounding box calculation: --exact



SVG-1.1, the current standard, is a single-page document format, primarily intended for creating vector graphics to be embedded in the HTML code of Web pages. Therefore, dvisvgm tries to calculate the tight Bounding Box around the content of the page, similar to what the standalone class is made for. One could also use the article class together with pagestyle{empty} to achieve the same result without using standalone; dvisvgm tries to crop the page around the visibile content.



In case of pure-text documents, without using graphical objects that push the page borders outwards, the resulting bounding box of the output is determined by the glyph boxes from the tfm files of the used font. However, these tend to be smaller than the glyphs themselves. This may lead to cropped output where parts of the glyphs are invisible because they are outside of the document edges.



dvisvgm provides option --exact to calculate the document's bounding box in such a way that glyph outlines fall entirely within the final bounding box.



Alternatively, the border option of the standalone document class can be set with a non-negative length value in order to add space around the content. This requires dvisvgm to be called with option --bbox=papersize. [Comment by @Martin]





Responsive SVG: --zoom=-1



Option --zoom=-1 produces "responsive SVG" that automatically scale to fill the available space. Such SVG don't have a fixed size. This is important for SVG to be embedded into a web page using HTML containers, such as <object> or <img>.



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="0", 5s="1" }
:rotate = { 6s="0", 10s="360", repeats, restart=false}
[fill = blue!20, draw = blue, ultra thick, circle]
{Hello!};

end{document}


Compile with:



latex texsx-469409
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409


HTML code for embedding:



<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="200"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="400"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg"/>







share|improve this answer





















  • 1





    The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

    – Martin
    yesterday













  • @Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

    – AlexG
    yesterday








  • 1





    @God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

    – AlexG
    yesterday








  • 1





    @AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

    – Martin
    yesterday








  • 1





    Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

    – AndréC
    1 hour ago



















6














Configuring Texstudio for dvisvgm



Magic comments



For texstudio a quick way to compile a svg animation are magic comments, i.e. the first line in the following file



% !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


This will run latex two times and afterwards convert it animated svg



Create a custom user command



Another approach is to create a custom user command. In the texstudio preferences->build add the line



 latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi


under "user commands":



enter image description here



Then one can find this open in the menu bar Tools->user->svg (or whatever name you chose in the previous step)



enter image description here



(In case dvisvgm is not in your path variable, replace dvisvgm in the above commands with the full path to its installation location)





Arara rule for dvisvgm



With the following rule for the cool automation tool arara



!config
identifier: dvisvgm
name: DVISVGM
commands:
- name: The dvisvgm program
command: >
@{
base = getBasename(file).concat('.dvi');
return getCommand('dvisvgm', base, options);
}
arguments:
- identifier: options
flag: >
@{
if (isList(parameters.options)) {
return parameters.options;
}
else {
throwError('I was expecting a list of options.');
}
}


the following document will produce an animated svg if compiled with arara



% arara: latex
% arara: latex
% arara: dvisvgm : {options: ['exact', 'font-format=woff', 'zoom=-1']}
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}





share|improve this answer


























  • Does TeXmaker offer the same possibilities as TexStudio?

    – AndréC
    2 days ago











  • @AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

    – samcarter
    2 days ago











  • Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

    – AndréC
    yesterday













  • @AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

    – samcarter
    yesterday






  • 1





    @AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

    – samcarter
    yesterday





















4














Incredible! Work even in PDF with the animate package of Alexander Grahn.



documentclass{article}
usepackage{tikz}
usetikzlibrary{animations}
usepackage{animate}
newcommand{myAnim}[1]{
begin{tikzpicture}[make snapshot of=#1]
draw (1,.5) circle [radius=1mm];
node :shift = {
along = {(0,0) circle[radius=5mm]} upright,
0s="0", 2s="1", begin on=click }
at (1,.5) [fill = blue, opacity=.5, circle] {Click};
end{tikzpicture}
}
begin{document}
pagestyle{empty}

begin{animateinline}[autoplay,loop]{2}
multiframe{5}{nSec=0+0.5}{
myAnim{nSec}
}
end{animateinline}
end{document}


enter image description here






share|improve this answer
























  • Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

    – AlexG
    yesterday











  • But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

    – AlexG
    yesterday











  • @AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

    – vi pa
    19 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469409%2fhow-do-we-compile-and-visualize-the-animations-of-tikz-3-1%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























4 Answers
4






active

oldest

votes








4 Answers
4






active

oldest

votes









active

oldest

votes






active

oldest

votes









18














Animations works only with the SVG format. So you should compile your example at first with latex (not pdflatex). Then you should run dvisvgm file which will show something like this in a command line



C:UsersXXXDocumentstests>dvisvgm test-utf8
pre-processing DVI file (format version 2)
processing page 1
graphic size: 66.670012pt x 51.11758pt (23.431829mm x 17.965775mm)
output written to test-utf8.svg
1 of 1 page converted in 1.64 seconds


You will then find a .svg-file in your folder which you can open in a browser or some other application that understand svg.



You can't
see the animations in pdf, but you can take snapshots:




  1. remove the dvisvgm option


  2. then run this with pdflatex





documentclass{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}
foreach t in {0.5, 1, 1.5, 2}
{
tikz[make snapshot of=t]
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};}

end{document}


enter image description here






share|improve this answer


























  • Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

    – AndréC
    2 days ago






  • 2





    @UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

    – berkus
    2 days ago






  • 1





    @AndréC sorry, typo. I meant "you can't see ...".

    – Ulrike Fischer
    2 days ago






  • 1





    The snapshots are for a pdf. Don't mix up the two methods.

    – Ulrike Fischer
    2 days ago






  • 1





    @berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

    – AlexG
    2 days ago
















18














Animations works only with the SVG format. So you should compile your example at first with latex (not pdflatex). Then you should run dvisvgm file which will show something like this in a command line



C:UsersXXXDocumentstests>dvisvgm test-utf8
pre-processing DVI file (format version 2)
processing page 1
graphic size: 66.670012pt x 51.11758pt (23.431829mm x 17.965775mm)
output written to test-utf8.svg
1 of 1 page converted in 1.64 seconds


You will then find a .svg-file in your folder which you can open in a browser or some other application that understand svg.



You can't
see the animations in pdf, but you can take snapshots:




  1. remove the dvisvgm option


  2. then run this with pdflatex





documentclass{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}
foreach t in {0.5, 1, 1.5, 2}
{
tikz[make snapshot of=t]
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};}

end{document}


enter image description here






share|improve this answer


























  • Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

    – AndréC
    2 days ago






  • 2





    @UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

    – berkus
    2 days ago






  • 1





    @AndréC sorry, typo. I meant "you can't see ...".

    – Ulrike Fischer
    2 days ago






  • 1





    The snapshots are for a pdf. Don't mix up the two methods.

    – Ulrike Fischer
    2 days ago






  • 1





    @berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

    – AlexG
    2 days ago














18












18








18







Animations works only with the SVG format. So you should compile your example at first with latex (not pdflatex). Then you should run dvisvgm file which will show something like this in a command line



C:UsersXXXDocumentstests>dvisvgm test-utf8
pre-processing DVI file (format version 2)
processing page 1
graphic size: 66.670012pt x 51.11758pt (23.431829mm x 17.965775mm)
output written to test-utf8.svg
1 of 1 page converted in 1.64 seconds


You will then find a .svg-file in your folder which you can open in a browser or some other application that understand svg.



You can't
see the animations in pdf, but you can take snapshots:




  1. remove the dvisvgm option


  2. then run this with pdflatex





documentclass{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}
foreach t in {0.5, 1, 1.5, 2}
{
tikz[make snapshot of=t]
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};}

end{document}


enter image description here






share|improve this answer















Animations works only with the SVG format. So you should compile your example at first with latex (not pdflatex). Then you should run dvisvgm file which will show something like this in a command line



C:UsersXXXDocumentstests>dvisvgm test-utf8
pre-processing DVI file (format version 2)
processing page 1
graphic size: 66.670012pt x 51.11758pt (23.431829mm x 17.965775mm)
output written to test-utf8.svg
1 of 1 page converted in 1.64 seconds


You will then find a .svg-file in your folder which you can open in a browser or some other application that understand svg.



You can't
see the animations in pdf, but you can take snapshots:




  1. remove the dvisvgm option


  2. then run this with pdflatex





documentclass{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}
foreach t in {0.5, 1, 1.5, 2}
{
tikz[make snapshot of=t]
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};}

end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago









berkus

614216




614216










answered 2 days ago









Ulrike FischerUlrike Fischer

188k7292673




188k7292673













  • Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

    – AndréC
    2 days ago






  • 2





    @UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

    – berkus
    2 days ago






  • 1





    @AndréC sorry, typo. I meant "you can't see ...".

    – Ulrike Fischer
    2 days ago






  • 1





    The snapshots are for a pdf. Don't mix up the two methods.

    – Ulrike Fischer
    2 days ago






  • 1





    @berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

    – AlexG
    2 days ago



















  • Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

    – AndréC
    2 days ago






  • 2





    @UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

    – berkus
    2 days ago






  • 1





    @AndréC sorry, typo. I meant "you can't see ...".

    – Ulrike Fischer
    2 days ago






  • 1





    The snapshots are for a pdf. Don't mix up the two methods.

    – Ulrike Fischer
    2 days ago






  • 1





    @berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

    – AlexG
    2 days ago

















Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

– AndréC
2 days ago





Is the dvisvgm command available on MikTeX? I don't see it on texmaker....

– AndréC
2 days ago




2




2





@UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

– berkus
2 days ago





@UlrikeFischer +1 Worked for me. However resulting svg file worked on Google Chrome and Firefox, not MS Edge.

– berkus
2 days ago




1




1





@AndréC sorry, typo. I meant "you can't see ...".

– Ulrike Fischer
2 days ago





@AndréC sorry, typo. I meant "you can't see ...".

– Ulrike Fischer
2 days ago




1




1





The snapshots are for a pdf. Don't mix up the two methods.

– Ulrike Fischer
2 days ago





The snapshots are for a pdf. Don't mix up the two methods.

– Ulrike Fischer
2 days ago




1




1





@berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

– AlexG
2 days ago





@berkus Soon, MS Edge will use the same rendering engine ("Blink") as Chrome. Everything's gonna be alright then ;-).

– AlexG
2 days ago











13














There are some dvisvgm command line options that are not mentioned in the TikZ manual, but which should generally be used.





Font format: --font-format=woff



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[varwidth]{standalone}
usepackage{amsmath}

begin{document}
Hello World!
begin{equation*}
int_0^1 2x dx = 1
end{equation*}
end{document}


Compile with:



latex texsx-469409-a
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409-a


The default font format that dvisvgm embeds in the SVG output is not correctly interpreted by most WEB browsers. Instead, browsers use some replacement font, e. g. Times. Also, mathematical symbols may be incorrectly displayed:





Therefore, always add option --font-format=woff!!! The default font format may change in future dvisvgm versions.







Improved bounding box calculation: --exact



SVG-1.1, the current standard, is a single-page document format, primarily intended for creating vector graphics to be embedded in the HTML code of Web pages. Therefore, dvisvgm tries to calculate the tight Bounding Box around the content of the page, similar to what the standalone class is made for. One could also use the article class together with pagestyle{empty} to achieve the same result without using standalone; dvisvgm tries to crop the page around the visibile content.



In case of pure-text documents, without using graphical objects that push the page borders outwards, the resulting bounding box of the output is determined by the glyph boxes from the tfm files of the used font. However, these tend to be smaller than the glyphs themselves. This may lead to cropped output where parts of the glyphs are invisible because they are outside of the document edges.



dvisvgm provides option --exact to calculate the document's bounding box in such a way that glyph outlines fall entirely within the final bounding box.



Alternatively, the border option of the standalone document class can be set with a non-negative length value in order to add space around the content. This requires dvisvgm to be called with option --bbox=papersize. [Comment by @Martin]





Responsive SVG: --zoom=-1



Option --zoom=-1 produces "responsive SVG" that automatically scale to fill the available space. Such SVG don't have a fixed size. This is important for SVG to be embedded into a web page using HTML containers, such as <object> or <img>.



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="0", 5s="1" }
:rotate = { 6s="0", 10s="360", repeats, restart=false}
[fill = blue!20, draw = blue, ultra thick, circle]
{Hello!};

end{document}


Compile with:



latex texsx-469409
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409


HTML code for embedding:



<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="200"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="400"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg"/>







share|improve this answer





















  • 1





    The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

    – Martin
    yesterday













  • @Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

    – AlexG
    yesterday








  • 1





    @God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

    – AlexG
    yesterday








  • 1





    @AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

    – Martin
    yesterday








  • 1





    Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

    – AndréC
    1 hour ago
















13














There are some dvisvgm command line options that are not mentioned in the TikZ manual, but which should generally be used.





Font format: --font-format=woff



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[varwidth]{standalone}
usepackage{amsmath}

begin{document}
Hello World!
begin{equation*}
int_0^1 2x dx = 1
end{equation*}
end{document}


Compile with:



latex texsx-469409-a
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409-a


The default font format that dvisvgm embeds in the SVG output is not correctly interpreted by most WEB browsers. Instead, browsers use some replacement font, e. g. Times. Also, mathematical symbols may be incorrectly displayed:





Therefore, always add option --font-format=woff!!! The default font format may change in future dvisvgm versions.







Improved bounding box calculation: --exact



SVG-1.1, the current standard, is a single-page document format, primarily intended for creating vector graphics to be embedded in the HTML code of Web pages. Therefore, dvisvgm tries to calculate the tight Bounding Box around the content of the page, similar to what the standalone class is made for. One could also use the article class together with pagestyle{empty} to achieve the same result without using standalone; dvisvgm tries to crop the page around the visibile content.



In case of pure-text documents, without using graphical objects that push the page borders outwards, the resulting bounding box of the output is determined by the glyph boxes from the tfm files of the used font. However, these tend to be smaller than the glyphs themselves. This may lead to cropped output where parts of the glyphs are invisible because they are outside of the document edges.



dvisvgm provides option --exact to calculate the document's bounding box in such a way that glyph outlines fall entirely within the final bounding box.



Alternatively, the border option of the standalone document class can be set with a non-negative length value in order to add space around the content. This requires dvisvgm to be called with option --bbox=papersize. [Comment by @Martin]





Responsive SVG: --zoom=-1



Option --zoom=-1 produces "responsive SVG" that automatically scale to fill the available space. Such SVG don't have a fixed size. This is important for SVG to be embedded into a web page using HTML containers, such as <object> or <img>.



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="0", 5s="1" }
:rotate = { 6s="0", 10s="360", repeats, restart=false}
[fill = blue!20, draw = blue, ultra thick, circle]
{Hello!};

end{document}


Compile with:



latex texsx-469409
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409


HTML code for embedding:



<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="200"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="400"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg"/>







share|improve this answer





















  • 1





    The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

    – Martin
    yesterday













  • @Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

    – AlexG
    yesterday








  • 1





    @God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

    – AlexG
    yesterday








  • 1





    @AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

    – Martin
    yesterday








  • 1





    Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

    – AndréC
    1 hour ago














13












13








13







There are some dvisvgm command line options that are not mentioned in the TikZ manual, but which should generally be used.





Font format: --font-format=woff



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[varwidth]{standalone}
usepackage{amsmath}

begin{document}
Hello World!
begin{equation*}
int_0^1 2x dx = 1
end{equation*}
end{document}


Compile with:



latex texsx-469409-a
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409-a


The default font format that dvisvgm embeds in the SVG output is not correctly interpreted by most WEB browsers. Instead, browsers use some replacement font, e. g. Times. Also, mathematical symbols may be incorrectly displayed:





Therefore, always add option --font-format=woff!!! The default font format may change in future dvisvgm versions.







Improved bounding box calculation: --exact



SVG-1.1, the current standard, is a single-page document format, primarily intended for creating vector graphics to be embedded in the HTML code of Web pages. Therefore, dvisvgm tries to calculate the tight Bounding Box around the content of the page, similar to what the standalone class is made for. One could also use the article class together with pagestyle{empty} to achieve the same result without using standalone; dvisvgm tries to crop the page around the visibile content.



In case of pure-text documents, without using graphical objects that push the page borders outwards, the resulting bounding box of the output is determined by the glyph boxes from the tfm files of the used font. However, these tend to be smaller than the glyphs themselves. This may lead to cropped output where parts of the glyphs are invisible because they are outside of the document edges.



dvisvgm provides option --exact to calculate the document's bounding box in such a way that glyph outlines fall entirely within the final bounding box.



Alternatively, the border option of the standalone document class can be set with a non-negative length value in order to add space around the content. This requires dvisvgm to be called with option --bbox=papersize. [Comment by @Martin]





Responsive SVG: --zoom=-1



Option --zoom=-1 produces "responsive SVG" that automatically scale to fill the available space. Such SVG don't have a fixed size. This is important for SVG to be embedded into a web page using HTML containers, such as <object> or <img>.



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="0", 5s="1" }
:rotate = { 6s="0", 10s="360", repeats, restart=false}
[fill = blue!20, draw = blue, ultra thick, circle]
{Hello!};

end{document}


Compile with:



latex texsx-469409
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409


HTML code for embedding:



<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="200"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="400"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg"/>







share|improve this answer















There are some dvisvgm command line options that are not mentioned in the TikZ manual, but which should generally be used.





Font format: --font-format=woff



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[varwidth]{standalone}
usepackage{amsmath}

begin{document}
Hello World!
begin{equation*}
int_0^1 2x dx = 1
end{equation*}
end{document}


Compile with:



latex texsx-469409-a
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409-a


The default font format that dvisvgm embeds in the SVG output is not correctly interpreted by most WEB browsers. Instead, browsers use some replacement font, e. g. Times. Also, mathematical symbols may be incorrectly displayed:





Therefore, always add option --font-format=woff!!! The default font format may change in future dvisvgm versions.







Improved bounding box calculation: --exact



SVG-1.1, the current standard, is a single-page document format, primarily intended for creating vector graphics to be embedded in the HTML code of Web pages. Therefore, dvisvgm tries to calculate the tight Bounding Box around the content of the page, similar to what the standalone class is made for. One could also use the article class together with pagestyle{empty} to achieve the same result without using standalone; dvisvgm tries to crop the page around the visibile content.



In case of pure-text documents, without using graphical objects that push the page borders outwards, the resulting bounding box of the output is determined by the glyph boxes from the tfm files of the used font. However, these tend to be smaller than the glyphs themselves. This may lead to cropped output where parts of the glyphs are invisible because they are outside of the document edges.



dvisvgm provides option --exact to calculate the document's bounding box in such a way that glyph outlines fall entirely within the final bounding box.



Alternatively, the border option of the standalone document class can be set with a non-negative length value in order to add space around the content. This requires dvisvgm to be called with option --bbox=papersize. [Comment by @Martin]





Responsive SVG: --zoom=-1



Option --zoom=-1 produces "responsive SVG" that automatically scale to fill the available space. Such SVG don't have a fixed size. This is important for SVG to be embedded into a web page using HTML containers, such as <object> or <img>.



LaTeX input (compile with latex or lualatex --output-format=dvi):



documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="0", 5s="1" }
:rotate = { 6s="0", 10s="360", repeats, restart=false}
[fill = blue!20, draw = blue, ultra thick, circle]
{Hello!};

end{document}


Compile with:



latex texsx-469409
dvisvgm --zoom=-1 --exact --font-format=woff texsx-469409


HTML code for embedding:



<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="200"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg" width="400"/>






<img src="https://agrahn.gitlab.io/svg/texsx-469409.svg"/>








share|improve this answer














share|improve this answer



share|improve this answer








edited 1 hour ago

























answered 2 days ago









AlexGAlexG

32.5k479144




32.5k479144








  • 1





    The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

    – Martin
    yesterday













  • @Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

    – AlexG
    yesterday








  • 1





    @God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

    – AlexG
    yesterday








  • 1





    @AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

    – Martin
    yesterday








  • 1





    Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

    – AndréC
    1 hour ago














  • 1





    The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

    – Martin
    yesterday













  • @Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

    – AlexG
    yesterday








  • 1





    @God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

    – AlexG
    yesterday








  • 1





    @AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

    – Martin
    yesterday








  • 1





    Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

    – AndréC
    1 hour ago








1




1





The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

– Martin
yesterday







The borders set with the border option of standalone can be applied to the SVG by calling dvisvgm with option --bbox=papersize. It tells the program to evaluate the papersize specials present in the DVI file rather than computing a tight bounding box (which is the default).

– Martin
yesterday















@Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

– AlexG
yesterday







@Martin I didn't try the obvious, but --bbox=dvi which didn't have the desired effect. Thank you for your comment! I edited the answer accordingly. (papersize isn't mentioned in the man page, version 2.3.5.)

– AlexG
yesterday






1




1





@God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

– AlexG
yesterday







@God No, :(. I linked them from my GitLab page. I used the the allowed <img> tag. It does not permit script driven animations, but the SMIL-type animations, that can be created with the new TikZ release.

– AlexG
yesterday






1




1





@AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

– Martin
yesterday







@AlexG Thanks for updating your answer. --bbox=papersize is available since version 1.16. I also updated the man page back then. So there should be some info about papersize specials in it. Perhaps you still have man page belonging to an older dvisvgm? The corresponding version number is mentioned at the bottom of the page.

– Martin
yesterday






1




1





Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

– AndréC
1 hour ago





Opera uses "Blink", if I'm not mistaken. I'm going back to opera.

– AndréC
1 hour ago











6














Configuring Texstudio for dvisvgm



Magic comments



For texstudio a quick way to compile a svg animation are magic comments, i.e. the first line in the following file



% !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


This will run latex two times and afterwards convert it animated svg



Create a custom user command



Another approach is to create a custom user command. In the texstudio preferences->build add the line



 latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi


under "user commands":



enter image description here



Then one can find this open in the menu bar Tools->user->svg (or whatever name you chose in the previous step)



enter image description here



(In case dvisvgm is not in your path variable, replace dvisvgm in the above commands with the full path to its installation location)





Arara rule for dvisvgm



With the following rule for the cool automation tool arara



!config
identifier: dvisvgm
name: DVISVGM
commands:
- name: The dvisvgm program
command: >
@{
base = getBasename(file).concat('.dvi');
return getCommand('dvisvgm', base, options);
}
arguments:
- identifier: options
flag: >
@{
if (isList(parameters.options)) {
return parameters.options;
}
else {
throwError('I was expecting a list of options.');
}
}


the following document will produce an animated svg if compiled with arara



% arara: latex
% arara: latex
% arara: dvisvgm : {options: ['exact', 'font-format=woff', 'zoom=-1']}
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}





share|improve this answer


























  • Does TeXmaker offer the same possibilities as TexStudio?

    – AndréC
    2 days ago











  • @AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

    – samcarter
    2 days ago











  • Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

    – AndréC
    yesterday













  • @AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

    – samcarter
    yesterday






  • 1





    @AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

    – samcarter
    yesterday


















6














Configuring Texstudio for dvisvgm



Magic comments



For texstudio a quick way to compile a svg animation are magic comments, i.e. the first line in the following file



% !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


This will run latex two times and afterwards convert it animated svg



Create a custom user command



Another approach is to create a custom user command. In the texstudio preferences->build add the line



 latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi


under "user commands":



enter image description here



Then one can find this open in the menu bar Tools->user->svg (or whatever name you chose in the previous step)



enter image description here



(In case dvisvgm is not in your path variable, replace dvisvgm in the above commands with the full path to its installation location)





Arara rule for dvisvgm



With the following rule for the cool automation tool arara



!config
identifier: dvisvgm
name: DVISVGM
commands:
- name: The dvisvgm program
command: >
@{
base = getBasename(file).concat('.dvi');
return getCommand('dvisvgm', base, options);
}
arguments:
- identifier: options
flag: >
@{
if (isList(parameters.options)) {
return parameters.options;
}
else {
throwError('I was expecting a list of options.');
}
}


the following document will produce an animated svg if compiled with arara



% arara: latex
% arara: latex
% arara: dvisvgm : {options: ['exact', 'font-format=woff', 'zoom=-1']}
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}





share|improve this answer


























  • Does TeXmaker offer the same possibilities as TexStudio?

    – AndréC
    2 days ago











  • @AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

    – samcarter
    2 days ago











  • Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

    – AndréC
    yesterday













  • @AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

    – samcarter
    yesterday






  • 1





    @AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

    – samcarter
    yesterday
















6












6








6







Configuring Texstudio for dvisvgm



Magic comments



For texstudio a quick way to compile a svg animation are magic comments, i.e. the first line in the following file



% !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


This will run latex two times and afterwards convert it animated svg



Create a custom user command



Another approach is to create a custom user command. In the texstudio preferences->build add the line



 latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi


under "user commands":



enter image description here



Then one can find this open in the menu bar Tools->user->svg (or whatever name you chose in the previous step)



enter image description here



(In case dvisvgm is not in your path variable, replace dvisvgm in the above commands with the full path to its installation location)





Arara rule for dvisvgm



With the following rule for the cool automation tool arara



!config
identifier: dvisvgm
name: DVISVGM
commands:
- name: The dvisvgm program
command: >
@{
base = getBasename(file).concat('.dvi');
return getCommand('dvisvgm', base, options);
}
arguments:
- identifier: options
flag: >
@{
if (isList(parameters.options)) {
return parameters.options;
}
else {
throwError('I was expecting a list of options.');
}
}


the following document will produce an animated svg if compiled with arara



% arara: latex
% arara: latex
% arara: dvisvgm : {options: ['exact', 'font-format=woff', 'zoom=-1']}
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}





share|improve this answer















Configuring Texstudio for dvisvgm



Magic comments



For texstudio a quick way to compile a svg animation are magic comments, i.e. the first line in the following file



% !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}


This will run latex two times and afterwards convert it animated svg



Create a custom user command



Another approach is to create a custom user command. In the texstudio preferences->build add the line



 latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi


under "user commands":



enter image description here



Then one can find this open in the menu bar Tools->user->svg (or whatever name you chose in the previous step)



enter image description here



(In case dvisvgm is not in your path variable, replace dvisvgm in the above commands with the full path to its installation location)





Arara rule for dvisvgm



With the following rule for the cool automation tool arara



!config
identifier: dvisvgm
name: DVISVGM
commands:
- name: The dvisvgm program
command: >
@{
base = getBasename(file).concat('.dvi');
return getCommand('dvisvgm', base, options);
}
arguments:
- identifier: options
flag: >
@{
if (isList(parameters.options)) {
return parameters.options;
}
else {
throwError('I was expecting a list of options.');
}
}


the following document will produce an animated svg if compiled with arara



% arara: latex
% arara: latex
% arara: dvisvgm : {options: ['exact', 'font-format=woff', 'zoom=-1']}
documentclass[dvisvgm]{standalone}
usepackage{tikz}
usetikzlibrary{animations}

begin{document}

tikz
node :fill opacity = { 0s="1", 2s="0", begin on=click }
:rotate = { 0s="0", 2s="90", begin on=click }
[fill = blue!20, draw = blue, ultra thick, circle]
{Click me!};

end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









samcartersamcarter

86.7k795279




86.7k795279













  • Does TeXmaker offer the same possibilities as TexStudio?

    – AndréC
    2 days ago











  • @AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

    – samcarter
    2 days ago











  • Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

    – AndréC
    yesterday













  • @AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

    – samcarter
    yesterday






  • 1





    @AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

    – samcarter
    yesterday





















  • Does TeXmaker offer the same possibilities as TexStudio?

    – AndréC
    2 days ago











  • @AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

    – samcarter
    2 days ago











  • Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

    – AndréC
    yesterday













  • @AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

    – samcarter
    yesterday






  • 1





    @AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

    – samcarter
    yesterday



















Does TeXmaker offer the same possibilities as TexStudio?

– AndréC
2 days ago





Does TeXmaker offer the same possibilities as TexStudio?

– AndréC
2 days ago













@AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

– samcarter
2 days ago





@AndréC I think that texmaker does not support magic comments -- I don't know if one can defines user commands (I'd always prefer texstudio over texmaker, it offers much more options)

– samcarter
2 days ago













Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

– AndréC
yesterday







Is it possible to add to the compilation command line "Open with Opera"? "Open with Chrome"? "Open with the default web browser"? etc.

– AndréC
yesterday















@AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

– samcarter
yesterday





@AndréC Yes, for example % !TeX TS-program = latex % | latex % | dvisvgm --exact --font-format=woff --zoom=-1 %.dvi | firefox %.svg works for me

– samcarter
yesterday




1




1





@AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

– samcarter
yesterday







@AndréC This depends on your operating system. On mac I can do open %.svg to open the file with the default program associated with the file type .svg (which is not necessarily a browser, depending how you configured your system)

– samcarter
yesterday













4














Incredible! Work even in PDF with the animate package of Alexander Grahn.



documentclass{article}
usepackage{tikz}
usetikzlibrary{animations}
usepackage{animate}
newcommand{myAnim}[1]{
begin{tikzpicture}[make snapshot of=#1]
draw (1,.5) circle [radius=1mm];
node :shift = {
along = {(0,0) circle[radius=5mm]} upright,
0s="0", 2s="1", begin on=click }
at (1,.5) [fill = blue, opacity=.5, circle] {Click};
end{tikzpicture}
}
begin{document}
pagestyle{empty}

begin{animateinline}[autoplay,loop]{2}
multiframe{5}{nSec=0+0.5}{
myAnim{nSec}
}
end{animateinline}
end{document}


enter image description here






share|improve this answer
























  • Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

    – AlexG
    yesterday











  • But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

    – AlexG
    yesterday











  • @AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

    – vi pa
    19 hours ago
















4














Incredible! Work even in PDF with the animate package of Alexander Grahn.



documentclass{article}
usepackage{tikz}
usetikzlibrary{animations}
usepackage{animate}
newcommand{myAnim}[1]{
begin{tikzpicture}[make snapshot of=#1]
draw (1,.5) circle [radius=1mm];
node :shift = {
along = {(0,0) circle[radius=5mm]} upright,
0s="0", 2s="1", begin on=click }
at (1,.5) [fill = blue, opacity=.5, circle] {Click};
end{tikzpicture}
}
begin{document}
pagestyle{empty}

begin{animateinline}[autoplay,loop]{2}
multiframe{5}{nSec=0+0.5}{
myAnim{nSec}
}
end{animateinline}
end{document}


enter image description here






share|improve this answer
























  • Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

    – AlexG
    yesterday











  • But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

    – AlexG
    yesterday











  • @AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

    – vi pa
    19 hours ago














4












4








4







Incredible! Work even in PDF with the animate package of Alexander Grahn.



documentclass{article}
usepackage{tikz}
usetikzlibrary{animations}
usepackage{animate}
newcommand{myAnim}[1]{
begin{tikzpicture}[make snapshot of=#1]
draw (1,.5) circle [radius=1mm];
node :shift = {
along = {(0,0) circle[radius=5mm]} upright,
0s="0", 2s="1", begin on=click }
at (1,.5) [fill = blue, opacity=.5, circle] {Click};
end{tikzpicture}
}
begin{document}
pagestyle{empty}

begin{animateinline}[autoplay,loop]{2}
multiframe{5}{nSec=0+0.5}{
myAnim{nSec}
}
end{animateinline}
end{document}


enter image description here






share|improve this answer













Incredible! Work even in PDF with the animate package of Alexander Grahn.



documentclass{article}
usepackage{tikz}
usetikzlibrary{animations}
usepackage{animate}
newcommand{myAnim}[1]{
begin{tikzpicture}[make snapshot of=#1]
draw (1,.5) circle [radius=1mm];
node :shift = {
along = {(0,0) circle[radius=5mm]} upright,
0s="0", 2s="1", begin on=click }
at (1,.5) [fill = blue, opacity=.5, circle] {Click};
end{tikzpicture}
}
begin{document}
pagestyle{empty}

begin{animateinline}[autoplay,loop]{2}
multiframe{5}{nSec=0+0.5}{
myAnim{nSec}
}
end{animateinline}
end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









vi pavi pa

452110




452110













  • Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

    – AlexG
    yesterday











  • But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

    – AlexG
    yesterday











  • @AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

    – vi pa
    19 hours ago



















  • Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

    – AlexG
    yesterday











  • But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

    – AlexG
    yesterday











  • @AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

    – vi pa
    19 hours ago

















Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

– AlexG
yesterday





Nice! I like your idea to build a wrapper around TikZ's SMIL-type animations that allows us to output frame-based animations with pkg animate.

– AlexG
yesterday













But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

– AlexG
yesterday





But this only works with linear animations, not branching ones, where objects are animated individually and interacted with by user action.

– AlexG
yesterday













@AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

– vi pa
19 hours ago





@AlexG Thanks, I don't know very well the animate package, certainly not well as you, I think. I make this try because the multiframe command look very similar at the foreach command suggested in the pgfmanual for get snapshots of the animation at a give time.

– vi pa
19 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469409%2fhow-do-we-compile-and-visualize-the-animations-of-tikz-3-1%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out