3

I created a batch file animator.bat taking two parameters (a TeX input filename without extension and the number of pages).

rem animator.bat 
rem %1 TeX filename without extension
rem %2 The number of pages

latex  "%~1"
latex  "%~1"
dvips  "%~1"

gswin64c -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile="%~1-%%d.ps" "%~1.ps"

latex --jobname="%~1" "\def\FileName{%~1-}\def\PageCount{%~2}\input{template}"
latex --jobname="%~1" "\def\FileName{%~1-}\def\PageCount{%~2}\input{template}"

dvisvgm --exact --font-format=woff --zoom=-1 --precision=1 "%~1"

for %%x in (aux log out toc ps dvi) do (if exist "%~1*.%%x" del "%~1*.%%x")

chrome "%~1.svg"

I also have a template template.tex as follows.

% template.tex
\documentclass[dvisvgm]{article}
\usepackage{animate,graphicx}

\begin{document}
\animategraphics[palindrome,controls,loop,autoplay,scale=1]{25}{\FileName}{1}{\PageCount}%
\end{document}

A test input file test.tex is given as follows.

% test.tex
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\def\f{x^2-x-6}
\psset{unit=3,algebraic}

\def\Atom#1{%
\begin{pspicture}(-1.5,-6.5)(1.75,-2.75)
    \psplot[linecolor=blue]{-1}{1}{\f}
    \psline[linecolor=green,linewidth=6\pslinewidth](-1,-3.5)(#1,-3.5)
    \psline[linecolor=green,linewidth=6\pslinewidth](0,0|*-1 {\f})(0,0|*{#1 .5 gt {.5}{#1} ifelse} {\f})
    \psline[linecolor=orange,linestyle=dashed](#1,-3.5)(*#1 {\f})(0,0|*#1 {\f})
    \pscircle*[linecolor=red](*#1 {\f}){2pt}
    \psaxes[linecolor=lightgray,Oy=-3.50,Dy=.25,Dx=.5]{->}(0,-3.5)(-1.49,-6.49)(1.5,-3)[$x$,0][$y$,90]
\end{pspicture}}

\begin{document}
\multido{\r=-1.0+.125}{17}{\Atom{\r}}
\end{document}

If I execute the batch

animator.bat test 17

it produces the following error.

processing page 1 PostScript error: undefined in resourcestatus
Operand stack: 10 --nostringval-- false CMSY10 CMSY10 Font CMSY10 CMSY10 CMSY10 false true

If I am not wrong, this error comes from the dvisvgm.

Question

How to fix it?

Last Update

And if I disable the \psaxes by commenting it, the error immediately vanishes.

Or by sandwiching with animateinline (that actually I don't like because it is not so flexible)

% example.tex

\documentclass[dvisvgm]{article}
\usepackage{pst-plot,animate}
\pagestyle{empty}

\psset{unit=3,algebraic}
\def\f{x^2-x-6}

\def\Atom#1{%
    \psplot[linecolor=blue]{-1}{1}{\f}
    \psline[linecolor=green,linewidth=6\pslinewidth](-1,-3.5)(#1,-3.5)
    \psline[linecolor=green,linewidth=6\pslinewidth](0,0|*-1 {\f})(0,0|*{#1 .5 gt {.5}{#1} ifelse} {\f})
    \psline[linecolor=orange,linestyle=dashed](#1,-3.5)(*#1 {\f})(0,0|*#1 {\f})
    \pscircle*[linecolor=red](*#1 {\f}){2pt}
    \psaxes[linecolor=lightgray,Oy=-3.50,Dy=.25,Dx=.5]{->}(0,-3.5)(-1.49,-6.49)(1.5,-3)[$x$,0][$y$,90]
}
\begin{document}
\begin{animateinline}[%
  begin={\begin{pspicture}(-1.5,-6.5)(1.75,-2.75)},
  end={\end{pspicture}},
  controls,autoplay,loop]{25}
\newframe
\multiframe{17}{r=-1.0+.125}{\Atom{\r}}
\end{animateinline}
\end{document}

and invoked

latex example
latex example
dvisvgm --exact --font-format=woff --zoom=-1 example

the output looks really good.

enter image description here

The lastest update

If I produce a multipage PDF first, convert it to a bunch of separate PS files and then animate with the following batch (builder.bat)

rem builder.bat 
rem %1 TeX filename without extension
rem %2 The number of pages


latex  "%~1"
latex  "%~1"
dvips  "%~1"
ps2pdf "%~1.ps"

gswin64c -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile="%~1-%%d.ps" "%~1.pdf"

latex --jobname="%~1" "\def\FileName{%~1-}\def\PageCount{%~2}\input{template}"
latex --jobname="%~1" "\def\FileName{%~1-}\def\PageCount{%~2}\input{template}"

dvisvgm --exact --font-format=woff --zoom=-1 "%~1"

for %%x in (aux log out toc ps dvi) do (if exist "%~1*.%%x" del "%~1*.%%x")

chrome "%~1.svg"

invoking builder test 17 produce as follows. Note that test.tex is the original input file without animateinline.

enter image description here

Now it has no labels.

  • You don't need the preview package. Dvisvgm produces a tight bounding box on its own. – AlexG Jan 4 at 6:13
  • Instead of preview, just add \pagestyle{empty}. – AlexG Jan 4 at 8:01
  • Compiling test.tex and template.tex manually works without a problem here (Linux). I am using Ghostscript-9.26. Note that latex should be run at least twice in general. (I am told to do so, if I run it manually on your example files.) – AlexG Jan 4 at 8:05
  • 1
    This is what I got: agrahn.gitlab.io/svg/template.svg – AlexG Jan 4 at 14:04
  • 1
    I can reproduce the problem on texlive2018 and windows with dvisvgm 2.4.2. With miktex which has dvisvgm 2.6 it works fine. I have also an experimental 64bit texlive with binaries from win32tex.org and dvisvgm 2.6.1 and this works fine too. – Ulrike Fischer Jan 6 at 14:18
3
+50

After removing the word chrome (which I don't have), I ran your initial sample files without any problems (same as AlexG etc) the svg animation (with axis values) automatically opens and run in IE (or EDGE if that's your default .svg handler)

Win 10 with a portable (32 bit) updated MiKTeX 2.9 (avoids any Admin/User issues) Thus blocked from using the standalone dvisvgm as suggested by Herbert (since it needs to hook into registry) No matter, I got no error messages from MiKTeX dvisvgm at that part of run.

My packages include (too many recent updates to itemise)
02/01/19 a number of relevant MiKTeX bins such as dvisvgm and some fonts
30/12/18 Animate, pstricks and others


I thus have to suggest

1) first check using where that you are only calling the MiKTeX version of dvisvgm.exe (for testing you could prefix it with the correct path to the MiKTeX bin)

2) if using an administered MiKTeX install run update both as Admin and User. Whilst there (since these fonts are part of 2013 amsfonts) it may be worth removing and reloading that package in case it is corrupted. Ensure in both user cases via MiKTeX-console that after update you run Tasks > Refresh database and especially font map files.


It took a lot longer to get an identical output in TexLive

After many false starts including .ps. not recognised and MiKTeX not found! (see similar message above) I updated a number of related TexLive packages via the GUI version of TL-Manager where I could more easily check which related packages had updates.

Multiple changes and updates needed to eventually get your same error message.

Solution to Clear

So based on comments I "backed Up" all packages and Updated All (A time consuming process in TL) Using the Taskbar Actions finally manually ensured Font Map & Filename DB's along with rebuilt Formats for good measure. (This flagged up a few tweaks needed to my config files.)

I also changed Ghost Script to one more compatible than the current latest.

1) Finally settled on a FULL portable GS version 9.25 (as the installed version 9.26 raised comments about version mismatch and my older minimal copy had caused some issues with path errors, my bad :-)

At this stage I suggest checking your version of GS and if not 9.25 then consider replacing (for now) a fully installed copy from https://github.com/ArtifexSoftware/ghostpdl-downloads/releases (avoid the 9.26 for now)

Once this is done you can add its path to the dvipsgm command similar to

dvisvgm --exact --font-format=woff --zoom=-1 --precision=1 "%~1" --libgs="C:\Program Files\GhostScript\gs9.25\bin\gsdll64.dll"

You will still get a minor runaway message from TeX Live due to a glitch in {pgffor.code.tex} but simply hit enter each of the two times and it will clear.


Thus my conclusion

If you update ALL TeX packages correctly to latest and add --libgs=GS9.25 to the TeX Native dvisvgm you will get the correct result each time (for now :-)

  • Please don't give up. The bounty is waiting for you. :-) – Artificial Hairless Armpit Jan 6 at 21:14
  • Its not the bounty, since there is nothing to "capture/correct", your code is good, its the stability of the surrounding supports that let it down! – KJO Jan 6 at 21:23
  • 1
    I feel a bit guilty that you dont get bounty back since your code was not at fault so I hope upvotes on your question at top will compensate. Regards – KJO Jan 12 at 1:53
  • The accepted answer will be decided later. :-) – Artificial Hairless Armpit Jan 12 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.