# LaTeX Bundle Extension

I was a longstanding Emacs user, and I was accustomed to some behaviour of the CDLaTeX package, though the LaTeX bundle provides very similar functionalities my LaTeX writting style (and some keybindings I were used to) were not really compatible with them. Thus I have written some small personal extensions.

The extension is available from this link (download updated 2007-11-7)

## Snippets

I was surprised that the LaTeX Bundle did not come with snippets for subscripts and superscripts.

```
_{$1}$0
```

activated by the `_`

key with `text.tex.latex string.other.math`

scope, and

```
^{$1}$0
```

activated by the `^`

key with `text.tex.latex string.other.math`

scope.

Finally I include a patch to the `tabular`

snippet to correct
the bug where an additional column separator (`&`

) is
added.

```
\\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
$0${2/((?<=[clr])(\|*(c|l|r)))|./(?1: & )/g}
\\end{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
```

bound to `tab`

tab trigger.

## Macro

The main functionality of the bundle is in the macro `LaTeX Symbol`

.
The key equivalent for the macro is `!`

. The macro works as follows

- it takes as input the current word (or string of characters)
- it checks whether the input is in LaTeX math mode (
`math`

scope in TextMate)- if not in math mode it encloses the input in math mode (by prefixing and postfixing
`$`

)

- if not in math mode it encloses the input in math mode (by prefixing and postfixing
- if the input matches one of the key inputs then it replaces the key input with the LaTeX symbol
for the key input. Otherwise
- if the key input is alphanumeric, it uses the last character as key input, and then replaces it with the corresponding symbol (if any);
- if the key input is not alphanumeric, it takes as input the sting of charchters excluding
the leading and trailing parenthesis, white spaces and dollar signs (i.e.,
`][}{)( $`

)

### Examples

In the examples below the characters on the left-hand side of `=>`

is the sequence of keys you type and the characters on the right-hand side is the output of the sequence.

```
a! => \alpha (math mode/math scope)
a! => $\alpha$ (non in math mode/math scope)
\alphab! => \alpha\beta
\alpha b! => \alpha \beta
a!b! => \alpha\beta
d! => \delta
\delta! => \partial
d!! => \partial
->! => \rightarrow
1! => !
```

The sequence `a!b!`

includes two steps: 1) `a!`

that produces `\alpha`

and then 2) `b!`

that produces `\beta`

. In the sequence `d!!`

, again, there are two substitutions, the first `d!`

producing `\delta`

, and then `\delta!`

produces `\partial`

. This essentially corresponds to level 1 and level 2 symbols in CDLaTeX package.

If you have to produce `1!`

please type `11!`

.

### Key Inputs

Here is the list of current key inputs

```
a => \alpha,
A => \forall,
b => \beta,
B => \Box,
c => \subset, subset => subseteq,
C => \supset, supset => supseteq,
d => \delta, delta => partial,
D => \Delta, Delta => Diamond,
e => \epsilon, epsilon => varepsilon,
E => \exists,
f => \phi, phi => varphi,
g => \gamma,
G => \Gamma,
h => \eta, eta => hbar,
i => \in, in => imath,
I => \Im,
j => \jmath,
k => \kappa,
l => \lambda, lambda => ell,
L => \Lambda,
m => \mu,
n => \nu,
N => \nabla,
o => \omega,
O => \Omega, Omega => mho,
p => \pi, pi => varpi,
P => \Pi,
q => \theta, theta => vartheta,
Q => \Theta,
r => \rho, rho => varrho,
R => \Re,
s => \sigma, sigma => varsigma,
S => \Sigma,
t => \tau,
T => \top, top => bot,
u => \upsilon,
U => \Upsilon,
v => \vee, vee => bigvee,
V => \Phi,
w => \xi,
W => \Xi,
x => \chi,
y => \psi,
Y => \Psi,
z => \zeta,
0 => \emptyset,
8 => \infty,
& => \wedge, wedge => bigwedge,
~ => \approx, approx => simeq,
+ => \cup, cup => bigcup,
- => \neg,
* => \times,
/ => \not,
' => \prime,
. => \cdot,
|- => \vdash,
|= => \models,
<-> => \leftrightarrow, leftrightarrow => longleftrightarrow,
<=> => \Leftrightarrow, Leftrightarrow => Longleftrightarrow,
-> => \rightarrow, longrightarrow => rightarrow,
<- => \leftarrow, longleftarrow => leftarrow,
<= => \Leftarrow, Longleftarrow => Leftarrow,
=> => \Rightarrow, Longrightarrow => Rightarrow,
~> => \leadsto,
| => \mapsto, mapsto => longmapsto,
< => \langle,
> => \rangle
```

## Bugs

The bundle seems to work for me. Please report bugs to me.