[OS X TeX] placeholders

Sime ungar at math.hr
Mon Nov 2 07:17:57 EST 2009



Herbert Schulz wrote:
> 
> 
> On Nov 2, 2009, at 4:20 AM, Sime wrote:
> 
>>
>> Dear list,
>> I am using TeXShop as the LaTeX editor, and in my CommandCompletion  
>> file I
>> have quite a few shortcuts like this one:
>>
>> grmp:=\begin{minipage}{#INS#mm}#RET#\begin{picture}(•) 
>> (0,0)\footnotesize#RET#\put(0,0){\includegraphics<•->[•]{•}}#RET#\end 
>> {picture}#RET#\end{minipage}~%#RET#\begin{minipage}{•mm}#RET#•#RET# 
>> \end{minipage}
>>
>> which triggered (in the above case by typing "grmp" and hitting  
>> ESCape key)
>> put
>>
>> \begin{minipage}{mm}
>> \begin{picture}(•)(0,0)\footnotesize
>> \put(0,0){\includegraphics<•->[•]{•}}
>> \end{picture}
>> \end{minipage}~%
>> \begin{minipage}{•mm}
>>>> \end{minipage}
>>
>> in my tex-file, with the insertion point in front of mm for the  
>> width of the
>> minipage .
>> (I use this particular shortcut to put a graphics parallel with some  
>> text in
>> a beamer presentation.)
>>
>> After inserting the number (of millimeters), hitting the TAB key  
>> takes me to
>> the first bullet (OPT+8), the next TAB puts the insertion point at  
>> the next
>> bullet, and so on.
>>
>> This has worked fine on my old TI PowerBook under Tiger, but it does  
>> not
>> work anymore on MacBook under Leopard. After a while I realized that  
>> all
>> this worked due to a small application, actually a PreferencePane,  
>> called
>> TextMacro. Trying to run it on the MacBook under Leopard I got "You  
>> cannot
>> open TextMacro preferences because it doesn't work on an Intel-based  
>> Mac". I
>> have contacted the author Mikael Langer, and he explained to me that  
>> as of
>> OSX 10.5 Apple has blocked the mechanism that makes TextMacro work.
>>
>> My question is: Does anyone know any substitute/replacement for  
>> TextMacro or
>> something similar? Would it be possible to implement such a thing in  
>> TeXShop
>> (e.g. like #INS# and #RET#)? What I currently do is to put the  
>> bullet into
>> the search field in the Find window and keep hitting CMD+G.
>>
>> I would appreciate any help.
>>
>>     Sime Ungar
>>
> 
> Howdy,
> 
> Attached are two applescripts that may help. You can add each one,  
> separately, to your Macros Menu using the Macros->Open Macro Editor...  
> and adding a new macro for each one. Unfortunately you won't be able  
> to assign the Tab key as the shortcut since the Cmd key is needed when  
> you define the shortcut in the Editor.
> 
> 
> 
> --AppleScript direct
> --delete `direct' for TeXShop v1.34
> --Next "Mark"
> --2005-10-10
> set searchString to "¥"
> try
>  tell application "TeXShop"
>   set searchOffset to (offset of selection of front document)
>   if (length of selection of front document) > 0
>    set searchOffset to (searchOffset + 1)
>   end if
>   tell front document
>    set firstOccurrence to (search for searchString starting from
> searchOffset)
>   end tell
>   if firstOccurrence > 0 then
>    set offset of selection of front document to (firstOccurrence - 1)
>    set length of selection of front document to (number of characters of
> contents of searchString)
> --   set content of selection of front document to ""
>   end if
>  end tell
> end try
> -- end of script
> 
> --AppleScript direct
> --delete `direct' for TeXShop v1.34
> --Previous "Mark"
> --2005-10-10
> set searchString to "¥"
> try
>  tell application "TeXShop"
>   set searchOffset to (offset of selection of front document)
>   tell front document
>    set firstOccurrence to (search for searchString searching backwards
> true starting from searchOffset)
>   end tell
>   if firstOccurrence > 0 then
>    set offset of selection of front document to (firstOccurrence - 1)
>    set length of selection of front document to (number of characters of
> contents of searchString)
> --   set content of selection of front document to ""
>   end if
>  end tell
> end try
> -- end of script
> 
> 
> 
> 
> 
> Good Luck,
> 
> Herb Schulz
> (herbs at wideopenwest dot com)
> 
> Thank you Herb, it works fine. I see I have to lern some AppleScript
> myself.
> 
> Best,
>     Sime
> 
> 
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/placeholders-tp3930925p3931455.html
Sent from the MacOSX-TeX mailing list archive at Nabble.com.



More information about the MacOSX-TeX mailing list