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

Paul A Norman paul.a.norman at gmail.com
Fri May 21 11:01:40 CEST 2010

Hi,

Insert a new \label{key}

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}

(Companion script to insertCrossRef.js)

Paul