[texworks] Using scripts

Stefan Löffler st.loeffler at gmail.com
Fri May 21 17:25:00 CEST 2010


Am 2010-05-21 17:03, schrieb Tyler Estler:
> You are very quick to respond, which is great!

You're lucky - I'm currently at my PC and have little enough to do to
fit in a mail or two occasionally ;).

> I am most interested in how scripts are executed in practice. For
> example, in WinEdt when I type \ref{} or \cite{}, dropdown lists of
> labels or bibliography entries appear, which is a wonderful feature.

Yes, and this is indeed planned for the (near?) future. However, the
scripting implementation is not that advanced yet, there's still room
for improvement ;).

> Such a feature appears to have been enabled in Tw by a script by Paul
> Norman. I would like to see an example of using this script, for example.

Partially, yes. It doesn't work as-you-type (you already noticed that),
and it doesn't present an inline list. Instead, it opens a dialog where
you can choose from several options.

To run the script, simply select "Insert Cross Reference" menu item from
the "Scripts" menu (or a submenu thereof, if you installed the script to
a subdirectory) in Tw. It should immediately bring up the dialog.
Since selecting a menu-item is not a very speedy thing to do when in the
middle of typing, you can also assign a shortcut to the script.
Unfortunately, the only way to do that at the moment is to edit the
script file directly. So if you open the "insertCrossRef.js" file in a
text-editor (you can even use Tw itself) from where you installed it,
you can add the following line somewhere in the first few lines (all
those starting with "//"):

//Shortcut: Alt+R

This will allow you to run the script by hitting Alt+R (you probably
need to reload the script list in Tw to make it work). You can even
define some more complex shortcuts, such as "Alt+I, Alt+R" which means
that you need to first hit Alt+I and then Alt+R to run the script. I
find this quite useful as I define all my insert commands to start with
Alt+I, for example, but this is a matter of taste.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texworks/attachments/20100521/81c120c1/attachment.html>

More information about the texworks mailing list