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.

AlexG
  • 54,894
Display Name
  • 46,933
  • You don't need the preview package. Dvisvgm produces a tight bounding box on its own. – AlexG Jan 04 '19 at 06:13
  • Instead of preview, just add \pagestyle{empty}. – AlexG Jan 04 '19 at 08: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 04 '19 at 08:05
  • 1
    This is what I got: https://agrahn.gitlab.io/svg/template.svg – AlexG Jan 04 '19 at 14:04
  • Seems to be font-related, the example in your update doesn't use fonts. – AlexG Jan 04 '19 at 14:19
  • Try to compile a minimal "Hello World" LaTeX file to SVG. – AlexG Jan 04 '19 at 14:46
  • Perhaps you should do a complete TeXLive installation. This is usually the default. – AlexG Jan 04 '19 at 15:24
  • Damn! I have no idea at the moment what could be done. Convert the test.ps to PDF and see whether fonts are embedded as Type-1. – AlexG Jan 04 '19 at 16:46
  • try it without -font-format=woff –  Jan 04 '19 at 17:43
  • and dvips -j1 <jobname> –  Jan 04 '19 at 18:14
  • dvisvgm --version is for me dvisvgm 2.3.5 and GhostScript 9.26. With TL2018 and Linux no problem. –  Jan 04 '19 at 18:20
  • and my last idea: run updmap-sys --force in the command window and try again. –  Jan 04 '19 at 18:22
  • https://dvisvgm.de/Downloads/ Does 2.6.1 help? If not I have no idea –  Jan 04 '19 at 18:35
  • 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 06 '19 at 14:18
  • You can get newer binaries at http://w32tex.org/, dvisvgm is in the dvitools package. – Ulrike Fischer Jan 06 '19 at 14:52
  • @UlrikeFischer Equally interesting my dvisvgm --version reports 2.4.2 (and works) but TeX Live is 32 bit –  Jan 06 '19 at 20:14
  • Works for me with up-to-date TeXLive-2019 (dvisvgm-2.3.6) and Ghostscript-9.26. – AlexG May 04 '19 at 15:01

2 Answers2

3

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 :-)

  • 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! –  Jan 06 '19 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 –  Jan 12 '19 at 01:53
1

Dvisvgm-2.6.3 included in TeXLive-2019 can embed multipage PDF. This may simplify the workflow for producing animated SVG.

Use the following template for the main document:

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

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

The batch script animator.bat may look as follows:

rem animator.bat 
rem %1 TeX filename without extension

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

latex --jobname="%~1" "\def\FileName{%~1}\input{template}"
latex --jobname="%~1" "\def\FileName{%~1}\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"

Run:

animator test
AlexG
  • 54,894