[OS X TeX] a user-defined engine for TeXShop (was adjusting TexShop's Bibliography macro)
Daniel Becker
daniel.becker at uni-rostock.de
Sat Mar 4 07:08:51 CET 2006
While the original problem can be solved with an apple-script macro
see other post, an engine can do the same job, that is running a
whole sequence of pdflatex, bibtex and makeindex that is necessary to
produce a valid pdf...
Thanks to Peter and Herb for explaining how to deal with filenames
etc in a shell-script etc. The script that works as expected is
documented below.
Daniel
>>> I tried (several hours) to adjust the Bibliography macro that
>>> comes with TexShop to my needs. All I want to do is to have two
>>> more runs than already present in the macro.
>> How about writing an "engine" for this job?
>>
>> An engine is a little shell script that does a complicated batch
>> job, for example like ps4pdf.engine.
>>
>> You can take as template one of the (makeindex) scripts in ~/
>> Library/TeXShop/bin and copy it under an easy to understand name
>> to ~/Library/TeXShop/Engines/<name>.engine, then add pdflatex and
>> other makeindex lines ... and in your TeX source put among the
>> first lines:
>>
>> %!TEX TS-program = <name>
>>
>> so that TeXShop texs your file with the right engine at once!
This is the engine file that does what I want:
#!/bin/tcsh
# pdflatex, bibtex,pdflatex,pdflatex,makeindex,pdflatex
set path = ($path /usr/local/bin /usr/local/teTeX/bin/`uname -p`-
apple-darwin-current)
set fbName = `basename "$1" .tex`
pdflatex --shell-escape "${fbName}"
bibtex --shell-escape "${fbName}"
pdflatex --shell-escape "${fbName}"
pdflatex --shell-escape "${fbName}"
makeindex -c -s indexkorr.ist "${fbName}.idx"
pdflatex --shell-escape "${fbName}"
again, the index-stylefile indexkorr.ist needs to be in
~/Library/texmf/makeindex/
or in the working directory. Also, the engines in ~/Library/TeXShop/
Engines/ need to be executable, therefore, in the terminal:
[Daniel-Beckers-Mac:~] daniel% chmod -R 755 ~/Library/TeXShop/Engines/
[Daniel-Beckers-Mac:~] daniel% ls -l ~/Library/TeXShop/Engines/
-rwxr-xr-x 1 daniel staff 110 Feb 5 03:50 XeLaTeX.engine
-rwxr-xr-x 1 daniel staff 107 Feb 5 03:50 XeTeX.engine
-rwxr-xr-x 1 daniel staff 423 Mar 4 06:52 fullrun.engine
-rwxr-xr-x 1 daniel staff 412 Mar 2 15:15 ps4pdf_Bilder.engine
>
> The 'set path' statement comes first, before any command is
> executed. A bit of optimisation can be to make it independent from
> the processor used in the Mac:
>
> set path = ($path /usr/local/bin /usr/local/teTeX/bin/`uname -p`-
> apple-darwin-current)
>
> pdflatex needs no '--shell-escape' accept is runs itself some
> external command or script.
>
> Invoke in Terminal 'chmod 755 fullrun.engine' (and for
> ps4pdf_Bilder.engine too).
>
>
>
> The problem is probably that the script receives the full file
> name. It might work with:
>
> makeindex -c -s indexkorr.ist `basename "$1" tex`idx
>
> '`basename "$1" tex`' converts the full path name with the file
> name's extension to the full path name without the extension "tex"
> but with the dot ".", so you just need to add "idx" for the full
> index name.
>
> Isn't it better to leave away the ".idx" extension? If so use this:
>
> makeindex -c -s indexkorr.ist `basename "$1" .tex`
>
> I think bibtex waits for a file name without extension, i.e.
> `basename "$1" .tex`. And since it's now more than once that
> basename is being used, it's worth to write:
>
> set fbName = `basename "$1" .tex`
>
> and then use "$fbName" instead of `basename "$1" .tex` and "$
> {fbName}.idx" instead of `basename "$1" tex`idx.
>
>
> And the first, commented makeindex, needs an argument like
> pdflatex, i.e. "$1".
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
More information about the macostex-archives
mailing list