42

I'm wondering if it is possible to add javascript animations in LaTeX Beamer, e.g. figures created with C3 or D3? As far as I remember the animate packages uses javascript in order to display (and probably run) the videos embedded in the document. There is a post on embedding JavaScript in LaTeX on StackExchange, but the post focuses on document-level Javascript in a PDF (no mentions on including third party libraries such as D3).

  • 4
    Welcome to TeX.SX! Not everybody is fluent with Javascript here; can you be more precise about what C3 and D3 mean? – egreg Oct 9 '14 at 17:27
  • for presentations that would be great! Unfortunately that basically requires embedding a browser viewport in the PDF. I would also be curious to know if that is possible. However you could also produce your slides using something like remark which runs in the browser already allowing you to embed such videos with an iframe – Bordaigorl Oct 9 '14 at 17:43
  • 5
    I think there is no drawing canvas object provided by AdobeReader's JavaScript engine which would be the basic requirement for runtime-generated graphics and animations. – AlexG Oct 16 '14 at 13:14
  • it is possible d3 can generate svg object, so as long as you insert svg to pdf, you are good to go. The problem is then; does latex have a JS engine? I am assuming graphic objects are compiled on-the-fly. – Ali Jan 5 '15 at 8:06
  • 1
    Just for reference to the comment by @AlexG: the Acrobat JavaScript Scripting Guide by Adobe. – ojdo Oct 21 '15 at 8:31
3

The answer to this question is embedded in the comments above. At the moment, there is no way to use JavaScript libraries like D3 and C3 as is; however, you could do similar things, if you wanted to write the code from scratch or modify those libraries to use the PDF object model OR export their graphics for use in LaTeX (see d3js/SVG Export demo)

Notes:

  1. LaTeX allows us to create PDF or PostScript (.ps) files
  2. PDF has its own document object model (DOM) (as referenced in the Acrobat JavaScript Scripting Guide p. 22). In other words, PDF supports JavaScript, but not the Browser DOM, which is the way the Browser displays lines, text and images on a page.
  3. D3 and C3 use the browser's DOM to draw on the page

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.