[texworks] SCRIPT: Insert a new \label{key} - checks for current Environment and potential duplicate conflict

Paul A Norman paul.a.norman at gmail.com
Sat May 22 09:32:03 CEST 2010


Hi,

Following up on Stefan's suggestion ...

Paul

newLabelforCrossRefsEnvCheck.js

As for newLabelforCrossRefs.js Inserts a new \label{key} but does a
check for an active/current environemnt e.g. \begin{figure} (Thanks to
Stefan for this added suggestion.)

http://code.google.com/p/texworks/issues/detail?id=261&q=SCRIPTS#c23

If a standard LaTeX environment is current where the cursor is, a
prefix from a standardised list for the label name is suggested, and a
brief description of the environment is given for User assistance and
confirmation (may remind people that an environment has not been
\end-ed!).

If a package or proprietary environment is current, a prefix
abbreviation is generated and suggested.

These standard LaTeX2e environemnts are treated as proprietary.

"flushleft",,"Flushed left lines. "
"flushright",,"Flushed right lines. "
"center",," Centred lines. "

And this is ignored "document",,"Enclose the whole document. "

If no environment is current at the cursor position, then no specific
prefix is suggested.

chapter, section et al, are left for the user to determine

And the user is responsible as to whether any current environment or
renewed environment fully supports \label{anyWay}

If text is selected first in the Tw editor, the script endeavours to
use this as the key to make a new \label{key}

Checks through the current document, and offers a drop-down box with
either a blank area to type in, or if the user has selected some text,
that as the proposed label key. The drop-down shows any already
existing label keys in the document.

If the user Ok-s the drop-down box, the script then checks through
existing labels to avoid reproducing the same key.

If the key has already been used in another \label{key} statement, the
user is shown the pre-existing key, and asked to try making a new
label up again. The same checks are performed recursively until either
a unique key is made, or the user cancels.

Successful use, inserts \label{usersKey} or \label{anyPrefix:usersKey}

Please advise of any problems or possible improvements.

(Companion script to insertCrossRef.js


More information about the texworks mailing list