[OS X TeX] keyboard shortcut for starred version of environments

Herbert Schulz herbs at wideopenwest.com
Tue Sep 20 14:02:05 CEST 2011


On Sep 19, 2011, at 7:53 PM, Murray Eisenberg wrote:

> I know how to insert a \begin{align}...\end{align) pair in TeXShop LaTeX source -- by typing "bal" and hitting Esc.
> 
> But...
> 
> 1. How would one insert the starred form of an enviornment, e.g.,
> \begin{align*}...\end{align*) ? I tried the obvious thing of typing "bal*" (without any quotes) and hitting Esc, but plainly that doesn't work.
> 

Howdy,

I usually put an `s' at the end of starred versions of environments. However, there is an easier way. Type `bal' and hit Esc to get the normal align and then just hit Esc again to get the * variant. You can keep on hitting Esc to get succeeding matches (aligned, etc.).

If you don't like the order of the items you can simply change the order in the CommandCompletion.txt file (it's searched backwards for matches). You can do this using Source->Command Completion->Edit Command Completion File… in TeXShop.

> Two related questions:
> 
> 2. Why does the auto-insertion of an environment such as \begin{align}...\end{align) automatically insert a place-holder _after_ the end of the environment?  That makes not sense to me -- in fact, it's an utter nuisance (whereas the placeholder inside the environment is at worst a mild irritant in that one has to replace it).
> 

I put that there so it's easy to get to the end of an environment (jumping over the \end{envname}, etc.). If you don't like them you can edit the CommandCompletion.txt file as mentioned above.

By the way, if you mess things up you can get the original file back by moving the ~/Library/TeXShop/CommandCompletion/ folder to your Desktop and re-starting TeXShop.

> 3. Is there some shortcut so that if I type an entire \begin{cmd} expression, then I can trigger a matching \end{cmd} after it?
> 
> That seems like such a natural thing to have -- you can quickly complete _any_ environment with it, including one you yourself defined in the preamble, without having to create some new macro just for that one particular environment.
> 

If you only want to add the \end{cmd} after writing the \begin{cmd} simply press Esc after writing the `}' of the \begin{cmd}.

If you want to add a complete command with Marks, etc., do the following. Write out the abbreviation; then :=; then the complete command where you replace Returns by #RET#; use #INS# where you want to cursor to be (or #INS#•#INS# to get fancier); add • (Source->Command Completion->Marks->Insert Mark [Cmd-8]) at each position you'll want to jump to add text; select the complete expression and add it to the CommandCompletion.txt file using  Source->Command Completion->Add Word (Shift-Cmd-W). So selecting

bcmdo:=\begin{cmd}[#INS#•#INS#]#RET#•#RET#\end{cmd}•

(I usually add an `o' at the end of abbreviations that have an Optional argument) and pressing Shift-Cmd-W adds that line to the CommandCompletion.txt file. Then writing

bcmd

(or bcmdo) and pressing Esc gives

\begin{cmd}[|•|]
•
\end{cmd}•

where |•| is a selected Mark in the optional argument. You can always edit the CommandCompletion.txt file to remove it if you don't like it. Additions are placed at the bottom of that file and are found before other abbreviations that match.

Hope this helps.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)






More information about the macostex-archives mailing list