guide latex
Written by Daniel Herber.
---
### Installation Steps ###
**Note**: This guide assumes you are running a recent version of 64-bit Windows. More instructions are available in the [LaTeXTools readme](https://github.com/SublimeText/LaTeXTools).
#### Install the Required Software ####
1. [Sublime Text 3](https://www.sublimetext.com/3) (64-bit)
- Alternatively, ```choco install sublimetext3``` using [chocolatey](https://chocolatey.org/)
2. [MiKTeX](https://miktex.org/download) (64-bit, Basic MiKTeX Installer)
- Alternatively, ```choco install miktex.install``` using [chocolatey](https://chocolatey.org/)
3. [Ghostscript](http://ghostscript.com/download/gsdnld.html) (64-bit, GNU Affero General Public License)
- Alternatively, ```choco install ghostscript.app``` using [chocolatey](https://chocolatey.org/)
4. [ImageMagick](http://www.imagemagick.org/script/binary-releases.php) (64-bit, Q16, static, 6.9.7 preferred)
- Available at ftp://ftp.imagemagick.org/pub/ImageMagick/binaries
5. [SumatraPDF](https://www.sumatrapdfreader.org/downloadafter.html) (64-bit)
- Alternatively, ```choco install sumatrapdf.install``` using [chocolatey](https://chocolatey.org/)
#### Update PATH Variable ####
If you are unsure what the `PATH` variable is in windows or how to change it, see the following [video](https://www.youtube.com/watch?v=W9pg2FHeoq8). The goal is to not receive the error `...is not recognized as an internal or external command...` in the Command Prompt for each of the steps.
1. Ensure that Sublime Text is in your path
- Run the command `sublime_text` in the Command Prompt and see if it is recognized
- If it isn't add the `Sublime Text 3` folder for Sublime Text to your path
- Typically is something like `C:\Program Files\Sublime Text 3`
2. Ensure that MiKTeX is in your path
- Run the command `texify` in the Command Prompt and see if it is recognized
- If it isn't add the `bin\x64` folder for MiKTeX to your path
- Typically is something like `C:\Program Files\MiKTeX 2.9\miktex\bin\x64`
3. Ensure that Ghostscript is in your path
- Run the command `gswin64c` in the Command Prompt and see if it is recognized
- If it isn't add the `bin` folder for Ghostscript to your path
- Typically is something like `C:\Program Files\gs\gs9.20\bin`
4. Ensure that ImageMagick is in your path
- Run the command `magick` in the Command Prompt and see if it is recognized
- If it isn't add the main folder for ImageMagick to your path
- Typically is something like `C:\Program Files\ImageMagick-6.9.7-Q16`
5. Ensure that SumatraPDF is in your path
- Run the command `SumatraPDF` in the Command Prompt and see if it is recognized
- If it isn't add the `SumatraPDF` folder for SumatraPDF to your path
- Typically is something like `C:\Program Files\SumatraPDF`
#### Install Package Control and LaTeXTools ####
1. Install [Package Control](https://packagecontrol.io/installation) using the information in the link. Package Control allows you to easily install and remove ST3 packages.
2. Install [LaTeXTools](https://github.com/SublimeText/LaTeXTools) using Package Control
- Hit `CTRL + SHIFT + P` to open the Command Palette
- Run `Package Control: Install Package`
- Install `LaTeXTools`
3. Now check the LaTeXTools setup
- Hit `CTRL + SHIFT + P` to open the Command Palette
- Run `LaTeXTools: Check System`
- Ensure that the status of everything listed is available
4. Review the LaTeXTools options navigating to `Preferences -> Package Settings -> LaTeXTools -> Settings - User`. Two options you might consider modifying:
- `"env_auto_trigger": true,`
- `"preview_math_density": 300,`
#### Setup Sumatra ####
You now need to set up inverse search in Sumatra PDF.
1. Open a Command Prompt.
2. Issue the following command (update names and paths appropriately):
```markdown
sumatrapdf.exe -inverse-search "\"C:\Program Files\Sublime Text 3\sublime_text.exe\" \"%f:%l\""
```
#### Build a Test File ####
1. Create a .tex file and place in it the following code:
```tex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Here is the text of your introduction.
\begin{align}
\alpha = \sqrt{ \beta }
\end{align}
\end{document}
```
2. Open the Command Palette (`CTRL + SHIFT + P`) and run `Build with LaTeX: Traditional `
3. You should now see `No errors. No warnings.` in the bottom panel of Sublime Text and a compiled pdf
4. Double click on a line in Sumatra to ensure the synctex is working
5. You have now built a LaTeX document with Sublime Text!
---
### Recommended Packages ###
Install packages via the Command Palette (`CTRL + SHIFT + P`) and `Package Control: Install Package`.
- [Side​Bar​Enhancements](https://github.com/titoBouzout/SideBarEnhancements) provides enhancements to the operations on Sidebar of Files and Folders for Sublime Text
- [BracketHighlighter](https://github.com/facelessuser/BracketHighlighter) matches a variety of brackets
- [Thesaurus](https://github.com/Nucc/Thesaurus) helps you in Sublime to find synonyms for the selected word and replace it with the chosen one.
- [Sublimerge 3](http://www.sublimerge.com/) is a professional diff & merge tool for Sublime Text
- [LaTeX-cwl](https://github.com/LaTeXing/LaTeX-cwl) provides better autocompletion of LaTeX commands
- [LaTeX Word Count](https://github.com/kevinstadler/SublimeLaTeXWordCount) is a SublimeText word and character count plugin for LaTeX and plaintext files
- [LaTeXTab](https://github.com/randy3k/LaTeXTab) allows you to copy a table in Excel and pasted it formatted into a LaTeX document
- [LaTeX Smart Quotes](https://github.com/r-stein/sublime-text-latex-smart-quotes) is to make the quotes in LaTeX "smart"
- [Non Text Files](https://github.com/bordaigorl/sublime-non-text-files) allows you to open certain file types from the sidebar (such as a PDF in Adobe Reader)
- [Git](https://github.com/kemayo/sublime-text-git) provides Git integration
- You will need to install [Git for Windows](https://git-scm.com/download/win) (64-bit)
- Alternatively ```choco install git.install``` using [chocolatey](https://chocolatey.org/).
- Run the command `git` in the Command Prompt and see if it is recognized
- If it isn't add the main folder for `Git\bin` to your path
- Typically is something like `C:\Program Files\Git\bin`
- [GitGutter](https://github.com/jisaacks/GitGutter) shows an icon in the gutter area indicating whether a line has been inserted, modified or deleted
- [Boxy Theme](https://github.com/oivva/st-boxy) is a set of easy customizable interface and syntax themes for ST3
---
### Additional Tips and Tricks ###
- ST3 basics
- [The Complete Visual Guide to Sublime Text 3: Getting Started and Keyboard Shortcuts](https://scotch.io/bar-talk/the-complete-visual-guide-to-sublime-text-3-getting-started-and-keyboard-shortcuts)
- [Sublime Text Tutorial by LearnWebCode](https://www.youtube.com/playlist?list=PLpcSpRrAaOaqQMDlCzE_Y6IUUzaSfYocK)
- [Shortcuts](http://docs.sublimetext.info/en/latest/reference/keyboard_shortcuts_win.html)
- Syncing ST3 settings between multiple computers ([link](http://adamdehaven.com/blog/2015/07/how-to-sync-sublime-text-packages-and-settings-across-multiple-computers-with-dropbox/)). Use any cloud syncing program such as Google Drive or Box.
- Turn on spell check by default ([link](https://forum.sublimetext.com/t/auto-spell-check-sublime-3/12930))
- To set a master file, you need to add the following line at the very top (i.e. as the first line) of any included files:
```tex
%!TEX root = yourmasterfile.tex
```
- You can use the package [nomencl](https://www.ctan.org/pkg/nomencl) to produce lists of symbols as in a nomenclature. See this [link](https://github.com/SublimeText/LaTeXTools/issues/503) for the solution which is to add the following line at the top of your master file:
```tex
\immediate\write18{makeindex -s nomencl.ist -o "\jobname.nls" "\jobname.nlo"}
```
- You can create a project file that adds the current folder and all subfolders to the project workspace and hide LaTeX specific temporary files. Simply download [latex.sublime-project](https://github.com/danielrherber/guides-danielrherber/blob/master/sublime-project/latex.sublime-project) or:
- Create a file named `latex.sublime-project` and place it in the root of your LaTeX project
- Copy the code found in [latex.sublime-project](https://github.com/danielrherber/guides-danielrherber/blob/master/sublime-project/latex.sublime-project)
- Now, just open the `latex.sublime-project` file when ever you want to work on this LaTeX project