[OS X TeX] Own commands

Alan Munn amunn at msu.edu
Mon Oct 26 11:44:26 EDT 2009


At 8:56 AM +0100 10/26/09, Ulrich Groh wrote:
>How can I "write" a command with the same behavior like the usage of 
>"bold" in the typography part of Latex palette, e.q.
>marking the word "this should be soemthing" with the mouse, going to 
>the LaTeX palette and use "my-own-command" which I can find there. 
>As result this should happen : \my-own-command{this should be bold}.

It's not completely clear what you're asking here, but I'll have a go.

First, the LaTeX panel has a "Custom" tab, which can be used to add 
up to 16 user defined buttons.  To change the buttons that are 
already there, you need to edit the file

  ~/Library/TeXShop/LaTeXPanel/completions.plist

At the end of that file there is a section called 
<key>Customized</key>.  You can add any commands there that you like.

(The default assignments are for section, subsection etc.)

Each entry in this section has two lines:
<string>Button Text</string>
<string>command to be inserted</string>

So for example, you could make a button for your \my-own-command by 
replacing one of the entries there in the following way:

<string>MyCommand</string>
<string>\my-own-command{#SEL##INS#}</string>

The #SEL# tells TeXShop to replace the selected text.  The #INS# 
tells TeXShop to put the cursor inside the braces if there is no text 
selected.

(I assume you know how to define your own LaTeX commands).

Alternatively, you can add any command you like using the Macro 
Editor.  You can then assign it to a key using the System Preferences 
-> Keyboard and Mouse setting.

In TeXShop, open the Macro Editor.  Create a new item with the name 
MyCommand, and in the macro box, type \my-own-command{#SEL##INS}.

Open the System Preferences, choose Keyboard & Mouse, and scroll down 
to the bottom.  There you can add specific applications. Click on the 
+ button, choose TeXShop in the pulldown menu.  Once you've chosen 
TeXShop, you can then add MyCommand and assign a key to it.  (Make 
sure it's spelled exactly as you spelled it in the Macro Editor.)

Alan
-- 
Alan Munn						amunn at msu.edu
Department of Linguistics
and Germanic, Slavic, Asian and African Languages		Tel. 
	517-355-7491
Michigan State University, East Lansing MI 48824 USA	Fax	517-432-2736



More information about the MacOSX-TeX mailing list