[TxMt] Label Table (for LaTeX) - final (so to say)
Piero D'Ancona
pierodancona at gmail.com
Tue Sep 26 16:55:01 UTC 2006
Hi,
so I'm posting this last message to share the "final"
version of the Label Table command; of course it is
very rudimentary and would need additional work, but
for me it does exactly what I need, so maybe it can
be useful for others too. I hope Haris or Allan like
it and add something like it to the Latex Bundle in
the future (who knows what's in the mind of masters
anyway).
I guess it is not possible to attach files from the web
gmane interface, so I am posting the command inside
the text. After all it takes 2 minutes to join back the long
sed commands into one line, copy and paste into the
bundle editor... Input: entire document, Output: HTML
file, scope: you choose.
The command creates an HTML window listing all the \label-s
of the topmost open window (only one file at the time, sorry).
Each label in the window is clickable, and clicking inserts text
at the insertion point in the open TextMate window.
If the label name starts with "eq", then \eqref{label_name}
is inserted; otherwise, only \ref{label_name}.
Best way to use the command: launch it the first time, the
HTML window opens; resize and put the window in a handy
position; then never close it, when you need it just issue the
command again (the window is refreshed and jumps over the
other windows).
Thanks to Allan for help.
Enjoy and improve,
Piero
TEXT OF THE COMMAND:
# parse the file for \labels (plus two lines following them)
sed -n -e "/\\label/{=;N;N;G;p;}" |
# separate labels from each other, the html way
sed '/^$/d' |
sed 's/^\([0-9]*\)$/\<p\>\<\/p\>\1/' |
sed 's/\(.\)$/\1\<br\>/' |
# the following two sed commands must be on one line each!
# do not insert spaces when joining lines
# insert active javascript links: for equations (we want \eqref here)...
sed 's/\\label{eq\(.*\)}/\<a href=\"javascript:TextMate.system
(\"\/usr\/bin\/osascript \&\>\/dev\/null -e @tell app \\\"
TextMate\\\" to insert \\\"\\\\\\\\eqref{eq\1}\\\"
@ \&\", null);\"\>\\label{eq\1}\<\/a>/' |
# ... and for the rest (sections, theorems etc.: we need \ref)
sed 's/\\label{\([^e][^q].*\)}/\<a href=\"javascript:TextMate.system
(\"\/usr\/bin\/osascript \&\>\/dev\/null -e @tell app \\\"
TextMate\\\" to insert \\\"\\\\\\\\ref{\1}\\\"
@ \&\", null);\"\>\\label{\1}\<\/a>/' |
# I used @ instead of ' for escaping reasons - put the quotes back
tr "@" "'"
More information about the textmate
mailing list