TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Before I go full into this software and explore it thoroughly, I have some questions that need to be answered.

How far can I automate or script LaTex using AppleScript? I am choosing applescript because of its Human-Language syntax and native intent on the Mac platform, integrating applications. There are many applications I am learning for my life's vocation.

I understand there are a range of other possible scripting languages such as perl, ruby, python and others; I have been looking at LaTex for a while now because I consider myself to be a citizen scientist - also the earth is not exactly in the best shape at this time.

If there any additional resources all of you can recommend in addition to the use of AppleScript already present, I would also greatly appreciate that.

share|improve this question
What exactly do you want to script, the document generation (like inserting text blocks automatically or on key press or generating entire documents) or the execution of LaTeX, BibTeX and co? – Chris Sep 11 '12 at 9:17
I'm certainly intellectually biased here, but IMHO the human-language aspect to Applescript is what limits its expressive power, to the point it's unusable (also it's slow, and badly documented if at all…). I would seriously recommend you start with a language that is more widely known and used, if only for the code and community you will be able to benefit from. – Damien Pollet Sep 11 '12 at 9:24
If you use TeXShop, macros can be written with Applescript – Corentin Sep 11 '12 at 10:13
I'm not sure what you mean by scripting LaTeX but if you have a recent distribution of MacTeX you'll have LuaTeX and you can write and run Lua scripts inside your TeX documents. – lhf Sep 11 '12 at 11:07
As others have noted, a lot depends on what you want to do. Applescript is mostly useful for interacting with Mac GUI applications. For good examples of this use, see TeXShop which has many such scripts. But the TeX binaries themselves are not Mac GUI applications, so depending on what you want to do, other scripting languages might be a better choice. Also, since Applescript allows you to call shell scripts from within an Applescript, it's possible to write hybrid scripts. This is what is done with many of the TeXShop Applescripts which are essentially wrappers for shell scripts. – Alan Munn Sep 11 '12 at 16:05

The answer is yes. As it has been said, from you AppleScript can run commandline commands which means one can run latex etc.

But the question is does it make sense?

AppleScript is a powerfull tool on macs, but has certain limitations. First of all it is bound to the mac environment. So porting AppleScript to other unix oss is rather complicated. Secondly the main feature of AS is the tell-interface, where one can access native mac applications (applications not apps!). I really can't see why one would need this in extend when scripting for TeX.

What you get in the end is a script written in a crude language, which is not even using the main feature of this language and absolutely bound to macs.

AppleScript an TeX make sense for me as long you are in the TeXShop univers, cause powering up TeXShop with AS is quite usefull. But for fully external scripting i recommend a real scripting language such as perl.

BTW: AS's humman-like interface isn't quite a humane as one could believe. As soon as your scripting needs come to the state that you need proper control-structures you have to learn AS like any other language.

share|improve this answer
Ah. Thank you for clearing that up. – Jonathan T. Allen Sep 14 '12 at 19:06

The only thing you need to script LaTeX is building strings, calling external programs (in this case pdflatex and maybe biber oder bibtex) and writing to files (your .tex file). All this is possible in AppleScript, so you could use it if you want.

But I would recommend using a language with more programming and template support. It seems from my Google Searches, that you can't use a template engine in AppleScript, which makes generating documents much easier. Any of your listed other scripting languages provide support for that.

share|improve this answer
Well I was thinking of building the basic document within LaTeX, then outputting to other software such as Adobe InDesign or Acrobat, Mac Word or Pages. Is there a specific this particular software is still very extensively used - other than portability - among scientists and engineers today as opposed to using other less granular software? – Jonathan T. Allen Sep 11 '12 at 10:38
Should this question be a separate post? – Jonathan T. Allen Sep 13 '12 at 1:19
Well this seems to be more a question of multiple output. You might have a look at johnmacfarlane.net/pandoc/index.html and the pandoc questions on TeX.SE tex.stackexchange.com/search?q=pandoc – bloodworks Sep 13 '12 at 8:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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