50

Here is Fran's example, based on the cited (now defunct) source: % Taken from Lena Herrmann at % http://lenaherrmann.net/2010/05/20/javascript-syntax-highlighting-in-the-latex-listings-package \documentclass{article} \usepackage{listings} \usepackage{color} \definecolor{lightgray}{rgb}{.9,.9,.9} \definecolor{darkgray}{rgb}{.4,.4,.4} \definecolor{purple}{...


29

Package hyperref 2012/10/12 v6.83i now implements the missing calculation order array in the /Form dictionary for the three driver classes that support PDF forms (pdftex, dvipdfm/xetex, pdfmark/dvips). If a field element contains calculation code, then this field element is automatically added to the calculation order array. Currently only document order is ...


29

Update: I am still improving the code style. You can find the latest version here: https://www.writelatex.com/74567mmxwkw - I appreciate anyone who is testing :) If you want to get a copy of the source code, you can get it here: https://dl.dropboxusercontent.com/u/74217418/stackexchange/tex/html5_listings_sample.tex After much trial and error and the help ...


26

This would require hacking the fancytooltips package. Since fancytooltips depends on packages which are not in TeXLive, I tried something on my own. The tool-tip command defined below supports all common output drivers (LaTeX workflows): latex->dvips->ps2pdf (dvips must not be called with option -Ppdf!) latex->dvipdfmx xelatex, lualatex, pdflatex The ...


17

The PDF specification requires that every form field that should be recalculated must be registered in the calculation order entry of the interactive form dicitionary (cf. pp. 416, 431). hyperref doesn't do this automatically though, so your JavaScript isn't taken into account by the viewer. The patch you mentioned should take up this job, but it doesn't ...


15

I want to provide an example that shows most of the possibilities. I hope it helps: \documentclass{article} \usepackage[pdfstartview=FitH]{hyperref} \begin{document} \begin{Form} \TextField[name = number.1, format = { var f = this.getField('number.1'); f.textFont = 'Verdana'; f.strokeColor = ['T']; ...


14

I merged the answers of @awx and @commonhare to get this gist: \usepackage{color} \definecolor{lightgray}{rgb}{.9,.9,.9} \definecolor{darkgray}{rgb}{.4,.4,.4} \definecolor{purple}{rgb}{0.65, 0.12, 0.82} \lstdefinelanguage{JavaScript}{ keywords={break, case, catch, continue, debugger, default, delete, do, else, false, finally, for, function, if, in, ...


14

Package media9 is an option. This example displays latest FIFA news in a Flash-based RSS-Reader I found on the web. It is embedded in the footline of every slide in a beamer presentation. It doesn't seem to update the content, though. However, it is reloaded (with updated content) when moving to the next presentation slide (Acrobat Reader required). \...


12

I do not want to spoil the fun, but there are some issues to consider. LaTeX is just a macro format/package for the macro language TeX. But there are many TeX compilers: TeX TeX with e-TeX pdfTeX XeTeX LuaTeX VTeX many other … A LaTeX file might depend on a particular compiler because it uses features of the compiler that are not provided by the ...


12

Vertical scrolling based on the animate package; definition of command \smoothScroll taken from an earlier post with slight modifications. As an example document, we take lppl.pdf from TEXMF/doc/latex/base/lppl.pdf, the pages somewhat trimmed. Update with suggestions incorporated: Start auto-scroll by clicking on the "widget", pause auto-scroll on mouse-...


11

the site has a paper with a how it works section https://mathapedia.com/books/31/sections/169/400 Looks quite impressive really. A version of Mathapedia that just requires client side code not a back end server is now at http://latex2html5.com/


11

On Linux at least (don't know about Windows), there is the latexdef script by Martin Scharrer, which looks up LaTeX definitions from the command line: latexdef section will print \section \long macro:->\@startsection {section}{1}{\z@ }{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus .2ex}{\normalfont \Large \bfseries } whereas latexdef sausage ...


10

I too think this is a great idea! As you suggested fetching the html tags and attributes from documentation, I went to the MDN page and found out they have all that info in a single html page. Based on another question by you, I've applied the same structure to all the tags, and it does work. Took me a while to realize that the order I was declaring each ...


9

This is a legit LaTeX compiler that runs in JavaScript. It does depend on some static files from the server (fonts, packages, etc), but it does not need server-side execution, this means that the data you insert on that page is not transmitted over the wire. Proof: I watched the HTTP stream using Webscarab after cleaning browser. There are HTTP requests, ...


9

The two column layout is possible using the multicol package. You can keep content in the two columns separate by putting \vfill \columnbreak after the content in the left hand column. The form is made using the hyperref package and its appearance and format can be changed using options that are explained in the hyperref manual. Here is a MWE that ...


7

One option is to use Lua to fetch data when the file is compiled. Then, set a batch script to recompile the TeX file every 30 seconds or so, and use a pdf reader that auto-refreshes the pdf file. Here is an example (in ConTeXt) that fetches the current date and time at a specific location from a webserver, parses the returned XML file, and displays the ...


7

The currently accepted answer misses a lot of keywords, so here's my language definition: \lstdefinelanguage{JavaScript}{ keywords={break, case, catch, continue, debugger, default, delete, do, else, finally, for, function, if, in, instanceof, new, return, switch, this, throw, try, typeof, var, void, while, with}, morecomment=[l]{//}, morecomment=[s]{/*...


7

If the TeX code for the format is myformat.tex, then pdftex -ini -etex -output-format=pdf myformat will produce the file myformat.fmt that you can place anywhere the TeX programs would search for formats; for instance in ~/texmf/web2c/pdftex/ The options: -ini means "be INITEX" (mandatory for building a format) -etex means "enable the e-TeX extensions (...


7

You might try the manual to the eforms package. eforms is another interface (other than hyperref) for creating PDF forms in TeX. The manual includes many simple examples. There is no DOM in PDF. If you want parts of the PDF to change based on form events, you pretty much have to make those changing things read-only text fields. For intermixing ...


7

Text and graphics which are the result of stroking and filling operations on a PDF document page cannot be accessed or modified using JavaScript. To a limited extent, PDF Layers (officially named Optional Content Groups, OCGs) can be used to mutually replace, hide or show page content in a PDF. But this does not necessarily involve JavaScript (see example ...


6

Try the following tex file: \documentclass{article} \usepackage[pdftex]{insdljs} \OpenAction{\JS{% app.alert("HALLO WELT"); }} \begin{document} THIS DOCUMENT IS A DOCUMENT \end{document} For more information, look at the official document!


6

The page objects in a PDF listen to page open (/O) and close (/C) events. Here is an example for using JavaScript actions (/S/JavaScript) with these events. Requires a recent media9 version and Adobe Reader X: \documentclass{beamer} \usepackage{media9} %%%%%%%%% adjust this %%%%%%%%%% \def\soundfile{sound_sample.mp3} %%%%%%%% /adjust this %%%%%%%%%% \...


6

Sure, e.g. with acrotex: \documentclass{article} \usepackage[pdftex]{eforms} \begin{document} \pushButton[\CA{Push me}\A{\JS{app.alert(Math.random())}}]{jsEx}{3cm}{12pt} \end{document} You can sent values to other fields: \documentclass{article} \usepackage[pdftex]{eforms} \begin{document} \textField{myField}{5cm}{12pt} \pushButton[\CA{Push me}\A{\JS{...


5

Yes, it is possible. Emscripten is quite powerful, there are ports of gnuplot, lua and various games. The github repository to the project has more information and the source files at https://github.com/manuels/pdftex.js. The author says It's under development and not ready to use, yet. So we have to wait a bit how the development progresses.


4

PDF as defined in the PDF norm has no facilities for viewer-dependent content. Its main goal is to be viewer-independent. So your only option are JavaScript actions supported by some viewers (notably Adobe's). AFAIK Java is not supported by any PDF viewers.


4

Take a look a the AcroTeX Education Bundle. The eforms package therein provides commands for creating JavaScript forms. If you want to reuse JavaScript code from form element to element you can use the insdljs package as you know about. There are a ton of examples with source code at the AEB site. Here's a short demo: \documentclass{article} \usepackage[...


4

\documentclass{article} \usepackage[pdftex]{eforms} \usepackage{graphicx} \usepackage{mwe} \newsavebox\img \sbox\img{\includegraphics{example-image-a}} \immediate\pdfxform\img \edef\normalappearance{\the\pdflastxform\space 0 R} \sbox\img{\includegraphics{example-image-b}} \immediate\pdfxform\img \edef\overappearance{\the\pdflastxform\space 0 R} \sbox\img{...


4

This can be done without JavaScript using PDF Layers (OCGs): (stateA.png) (stateB.png) \documentclass{article} \usepackage{ocgx2} \usepackage{graphicx} \begin{document} \switchocg{imgA imgB}{% \makebox[0pt][l]{% \begin{ocg}{Image A}{imgA}{on} \includegraphics{stateA} \end{ocg}% }% \begin{ocg}{Image B}{imgB}{off} \includegraphics{...


4

Indeed, the standard output is empty. Likely it get's read out internally for the message panel before your call (This would be a bug, or at least a misleading description in the documentation). In your case, you can use this code: %SCRIPT var res=system("texdoc --version"); res.standardOutputRead.connect( function(output) { editor.write(output); }); ...


4

This is a nice example to illustrate the basic use of timeline files and of the animate JavaScript programming interface. JavaScript is being used to loop over a sub-range of animation frames. Instead of repeating the animation from the very beginning, we want to jump back to the start of the second cycle which starts with a green dot at the zero degree ...


Only top voted, non community-wiki answers of a minimum length are eligible