[OS X TeX] Can You Find The Class?

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Sat Jun 18 20:23:32 CEST 2005


Herb,

Below is an Applescript that reveals the documentclass, to be used in  
TS. You have the subroutine setnamets.scpt.

Claus

tell application "TeXShop"
     get path of document of window 1
     set fileName to result
end tell

set scriptPath to (do shell script "dirname " & "~/Library/Flashmode/ 
Subroutines/ex")
set scriptPath to scriptPath & "/setnamets.scpt"
set scriptName to POSIX file scriptPath as alias
set scriptLiB to (load script scriptName)
tell scriptLiB
     set {baseName, texName, pdfName, namePath, dirName,  
dirNameunquoted, logName, logPath, rtfName} to setnamets(fileName)
end tell


set findString to "\\documentclass "


set foundboolean to "false"
try
     set shellScript to "cd " & dirName & ";"
     set shellScript to shellScript & "/usr/bin/egrep -w " &  
findString & " " & texName
     do shell script shellScript

     set foundText to result
     set foundboolean to "true"
end try
if foundboolean is equal to "true" then
     set n to (number of characters of contents of foundText)
     set i to 1 as number

     repeat while i < (n + 1)
         if character i of foundText is equal to "{" then
             set k to i
             exit repeat
         else
             set i to (i + 1)
         end if
     end repeat
     set i to k + 1 as number

     repeat while i < (n + 1)
         if character i of foundText is equal to "}" then
             set m to i
             exit repeat
         else
             set i to (i + 1)
         end if
     end repeat


     set className to (characters (k + 1) thru (m - 1) of foundText  
as string)
else
     beep
end if

On Jun 18, 2005, at 19:34, Herbert Schulz wrote:

> Howdy,
>
> Is there a (possibly low level) LaTeX command that allows a package  
> writer to find out the name of document class file (without  
> the .cls would be nice) for a given document? I was looking at  
> latex.ltx but it certainly wasn't clear to me.
>
> Good Luck,
>
> Herb Schulz
> (herbs at wideopenwest.com)
>
>
> --------------------- 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 Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
>
>
>

--------------------- 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 Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the macostex-archives mailing list