# Neat trick: Embedding applescript source code in LaTeX

3 messages
Open this post in threaded view
|

## Neat trick: Embedding applescript source code in LaTeX

 Aloha, Here is a neat trick. You can embed in a link in LaTeX an applescript. When the link is clicked the Applescript Editor opens with the code inserted. Try the following, \documentclass{article} \usepackage{hyperref} \begin{document} \href{applescript://com.apple.scripteditor?action=new\%26script=display\%20dialog\%20\%22hello\%22}{Click me!} \end{document} You can use a utility named ApplescriptHTML  to do most of the conversion for you (it generates HTML so you have to escape % to \% for it to work in LaTeX). I am adding similar functionality to my "TeXShop Webpage Helper" so we could embed TeX in links in web pages and PDFs that open in TeX. Imagine having a symbols list in a PDF or favorite snippets and clicking on a link and then having the code inserted into your current document or a new one. You do not have to worry about the encoding because I have already written a TeXShop macro that does all the ugly work: you select some text, run the macro and an encoded URL for the protocol texshop:// is placed in the clipboard. We could write live LaTeX manuals and tutorials for our students. Anyway I am geeked :) Mahalo, Ramón