[OS X TeX] LaTeX with TextMate
Charilaos Skiadas
skiadas at hanover.edu
Sun Jan 21 18:58:37 EST 2007
On Jan 21, 2007, at 5:41 PM, Michael S. Hanson wrote:
> One of my New Year's resolutions has been to learn TextMate, in
> order to work in a single editor for LaTeX, Matlab, Stata, etc.
> However, I am finding TM rather difficult. Over the past few weeks
> I have accumulated a number of questions specific to using TM with
> LaTeX; a few basic ones are below. I would greatly appreciate any
> input from the more experienced users of TM that I see occasionally
> posting on this list. (Please note that I have attempted to find
> the answers to these questions on-line, but without success.
> Chances are, I'm not looking in the correct places, so pointers are
> also appreciated.)
First of all let me point you to my website with lots of articles and
screencasts on LaTeX in TM:
http://skiadas.dcostanet.net/afterthought/list-of-my-textmate-pages/
Though perhaps you are already familiar with it.
Also, let me point you to the TextMate user's mailing list, which
might be a better place for questions about LaTeX in TM (since there
are a lot more LaTeX + TM users there than here): http://
macromates.com/community
> 1. With all the recent changes in the (La)TeX distributions for
> Mac OS X, how do I tell TextMate which distribution to use? I have
> more than one now installed on my Mac.
TextMate will automatically use whichever distribution you have told
your shell to use (at least it should do so, if it doesn't then we
can troubleshoot it further). The basic Typeset&View command sources /
etc/profile, and hence gets all the necessary customization from
there. The other commands try to locate the active kpsewhich through
a couple of heuristics, resorting to sourcing /etc/profile if they
can't find the active kpsewhich with the heuristics.
If you want to tell TextMate to use a distribution that is not the
one you have told your shell to use, then we can see what we can do
about it, but you'll have to explain your situation a bit more in
that case.
> 2. How do I get the window that pops up when compiling (like the
> "Console" in TeXShop) to reappear so that I can actually read the
> warnings that go whizzing by?
>
In the Help inside the LaTeX bundle, look at section "3.4 Preview
Options".
> 3. Autocompletion does not appear to work for me. If I type in
> some characters (say, the start of a common LaTeX command) and
> press [Escape], all I get it a "beep" and nothing else.
Which command was that? TextMate knows about a bunch of commands, for
instance typing "\f" and then pressing escape over here cycles among
\flat, \forall and \frac. But perhaps we have missed some commands.
Also, in general it is better to generate commands via the "cmd+}"
combo (that's "cmd+shift+]" in US keyboards). For instance typing
"sub" and pressing the cmd+} combo creates a subsection. You can set
all these shortcuts up via the "Edit Configuration File" command.
> 4. How do I get the syntax highlighting to show brackets {} in a
> different color? (Like TeXShop does....) I've tried various
> themes without success.
As it is, there is a way to do this that would unfortunately also
color a lot of other punctuation. To explain in greater detail,
TextMate uses something it calls [scope selectors][http://
macromates.com/textmate/manual/scope_selectors#scope_selectors]. Each
location in the text has an accompanying "scope selector", which you
should think of as CSS selectors if you are familiar with them. These
allow TM to target particular "contexts" in which to act. For
instance it allows it to color code in an lstlisting environment
according to some other programming language, instead of treating it
as TeX. It also allows the same shortcut to correspond to various
commands, depending on the context (for instance bibliography
completion inside a \cite{...}, label completion inside a \ref{...},
command completion when in a word starting with a backslash, regular
text completion otherwise, and so on.
The way a theme colors a document is by assigning colors to
particular scope selectors. Then any region with that scope selector
gets the corresponding color.
So to make TextMate highlight brackets, you need to add a new
instruction to some theme. So first off choose the theme you overall
like the most. Then, back to the text, place the caret behind a
bracket, and press ctrl-shift-p. This will show you the current scope
at the location following the caret. For instance in a line like:
\documentclass{article}
it may say something like:
text.tex.latex
meta.group.braces.tex
punctuation.section.group.tex
The first of those signals basically that we are in LaTeX context,
the other have to do with the brace and what follows it. One way to
target these braces is as follows. Go back to the Theme editor
(Preferences -> Fonts & Colors), and click on the little plus sign to
add a new rule. Name it however you like (I named it LaTeX Braces),
and chose whatever FG color you want (or BG color if you prefer
that). In the box that says "Scope Selector", type, without the
quotes: "text.tex.latex meta.group.braces punctuation"
This should already highlight most braces. It will miss things like
\begin{document}. To get those as well, make the scope selector say:
"text.tex.latex meta.group.braces punctuation, text.tex.latex
meta.function punctuation.definition.arguments".
This still misses some braces unfortunately, and I am working on
finding a more elegant way about it that would target braces and just
braces. Hopefully we'll figure something out soon, but I think this
should take care of most cases for you.
With a bit more work you should be able to color nested braces
differently, depending on the level of nesting.
> Thanks in advance for any help on these questions.
>
> -- Mike
>
Haris
------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/
More information about the MacOSX-TeX
mailing list