text editor textnate - joaomlourenco/novathesis GitHub Wiki

TextMate 2

TextMate uses a "Bundle" system to handle LaTeX. The key advantage here is the LaTeX Bundle, which is pre-installed but highly customizable through environment variables.

Requirements

  • macOS: TextMate is Mac-exclusive.
  • MacTeX: The standard distribution for Mac. Ensure it is installed so pdflatex and latexmk are in your path.
  • Perl: Pre-installed on macOS, required for latexmk.

Configuring Latexmk (The "TextMate Way")

TextMate’s LaTeX bundle is designed to detect and use latexmk automatically if configured correctly. Instead of changing deep internal settings, you use Environment Variables.

  1. Open TextMate > Settings (or Cmd + ,).
  2. Go to the Variables tab.
  3. Ensure the following variables are set (click the + to add):
  • PATH: Make sure this includes your TeX distribution path (usually /Library/TeX/texbin:/usr/local/bin:$PATH).
  • TM_LATEX_VIEWER: Set this to Skim if you use the Skim PDF reader (highly recommended for its sync features), or leave it blank to use the built-in TextMate viewer.
  • TM_LATEX_COMPILER: Set this to latexmk. This tells the bundle to use the automation engine instead of a single-pass compiler.

Usage

1. Typeset & View

Press Cmd + R. Because you set TM_LATEX_COMPILER to latexmk, TextMate will:

  • Run pdflatex.
  • Check for missing citations or references.
  • Run bibtex or biber automatically.
  • Re-run until the document is perfect.

2. Master Files

If your project has multiple files (e.g., chapters/intro.tex), you don't want to compile the chapter file alone.

  • At the top of your chapter file, add this line: %!TEX root = ../main.tex
  • TextMate will now always compile main.tex even when you are editing a sub-file.

3. LaTeX Selectors & Completion

  • Cmd + {: Wraps the current word in a \begin{env} ... \end{env} block.
  • Ctrl + Shift + W: Wraps selection in a command (e.g., \textbf{}).
  • Esc: Triggers "Completion." If you type \equ and hit Esc, it will cycle through equation, eqnarray, etc.

Essential Add-ons

Tool Purpose
Skim A lightweight PDF reader that supports Forward and Backward Search with TextMate. In Skim settings, go to Sync and select "TextMate."
latexindent If you want to auto-format your code, install this via MacTeX. You can trigger it in TextMate by searching for the "Tidy" command in the Bundle menu.

Spell Check

TextMate uses the native macOS spell checker.

  • To enable: Edit > Spelling and Grammar > Check Spelling While Typing.
  • Pro Tip: Because TextMate is "Scope Aware," it is smart enough not to spell-check your LaTeX commands (like \includegraphics), only the actual text content.

Note on LuaLaTeX/XeLaTeX: If you need to use a specific engine via latexmk, create a file named .latexmkrc in your project folder with the line $pdf_mode = 4; (for LuaLaTeX) or $pdf_mode = 5; (for XeLaTeX). TextMate will respect this file automatically.