[OS X TeX] Number of pages with AppleScript in TeXShop

Maarten Sneep maarten.sneep at xs4all.nl
Tue Oct 18 17:23:46 EDT 2005

On 18 Oct 2005, at 22:50, Simon Spiegel wrote:

> Ok, using shell and grep (and with help from the MacAchaia) I was  
> able to do a page count. But here comes the next problem: How can I  
> find the root file with AppleScript if I use \include?

If you went to the shell already, and if you're using one of the in- 
file techniques used by TeXShop (%SourceDoc filename or %!TEX  
Root=filename)), you could use my AppleScript/ShellScript combo as an  
example. Snippet:

# find the real master file (TeXShop 2.0 Style first)
sourcedoc=`awk -F= '/^%!TEX *[Rr]oot/{print $2}' < $frontdoc`

# if the new method didn't give a result, try the old method:
if [ "$sourcedoc" = "" ]; then
     sourcedoc=`awk '/^%SourceDoc/{print $2}' < $frontdoc`

I realise just now that this only works on files without spaces in  
their names. How does TeXShop do this (does it actually work?) I  
guess I should be using sed or cut to get the correct value. OK,  
we'll add a statement that support for filenames with spaces is limited.

The complete script also contains code to fine the main document  
class, and pass options to that class or packages without altering  
the files themselves: typeset with draft mode on once to get the page  
references correct, and then a final time to actually include the  
figures. Gives a nice speedup.

The current release is on the iso of the mactex project (or you  
browse the checked out cvs tree linked from http://www.tug.org/ 
mactex). You'll need either TextWrangler or BBEdit or open the  
AppleScripts (to see how I call the shell script), but the shell  
script can be used from the command-line (no help available though).


------------------------- 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 MacOSX-TeX mailing list