TIP: how to use TeXShop engines with any front end

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

TIP: how to use TeXShop engines with any front end

Ramón Figueroa-Centeno
Aloha,

One of the many powerful features of TeXShop is its engines. So what if you want to use the command line or another editor and still benefit from TeXShop's engines? Well you still can. Here is how:

(1) You must have TeXShop installed and running.
(2) You must specify the engine you want to use using the "%!TEX TS-program = " directive in your document (see the TeXShop help for information on this). For example, in the first 20 lines of your document include the line

%!TEX TS-program = pdflatexmk

to use Herb Schulz's pdflatexmk engine (aside from the engines installed in ~/Library/TeXShop/Engines, you can use tex, latex, pdftex, pdflatex, personaltex and personallatex; the default is pdflatex).
(3) Have your editor use the following bash script, which I call texshop, to typeset:

#!/bin/bash

PATH="$PATH:/usr/texbin:/usr/local/bin"

engines="$HOME/Library/TeXShop/Engines"
               
for var in "$@"; do
                        engine=`head -n20 "$var" | grep '% *!TEX TS-program' | head -n1 | sed 's/.*= *\([^ ]*\)/\1/g'`

        if [ "$engine" != "" ]; then
                case "$engine" in
                        tex)
                                engine=`defaults read TeXShop TexGSCommand`
                                ;;
                        latex)
                                engine=`defaults read TeXShop LatexGSCommand`
                                ;;
                        pdflatex)
                                engine=`defaults read TeXShop LatexCommand`
                                ;;
                        pdftex)
                                engine=`defaults read TeXShop TexCommand`
                                ;;
                        personaltex)
                                engine=`defaults read TeXShop TexScriptCommand`
                                ;;
                        personallatex)
                                engine=`defaults read TeXShop LatexScriptCommand`
                                ;;
                        *)
                                if [ -f "$engines/$engine.engine" ]; then
                                        engine="$engines/$engine.engine"
                                else
                                        engine=`defaults read TeXShop LatexCommand`
                                fi
                esac
        else
                engine=`defaults read TeXShop LatexCommand`
        fi
               
        $engine "$var"

done

----------------

Enjoy!

Ramón