LaTeX is a markup language that is often used for writing scientific documents. Sublime Text is a text editor which I like for its speed, looks and simplicity. I am currently writing a math assignment in LaTeX with Sublime Text 3 and I want to share my setup.
- Run Command On Sublime Text For Mac Os X
- Run Command On Sublime Text For Mac Os X Terminal
- Sublime Text Command Line Install
- Sublime Text Command Line
- Run Command On Sublime Text For Macro Multiple Times
If you want to open the file file.txt with Sublime Text from the command line. In OS X Mavericks running Sublime Text 2 the following worked for me. For anyone looking for opening a file with Sublime on mac from terminal. Open 'path/file.txt' -a '/Applications/Sublime Text.app'. Sublime Text 3 (ST3) is the latest version of one of the most commonly used plain text editors by web developers, coders, and programmers. It’s available for Mac, Windows, and Linux, and free to download and use.
With my setup I can create a PDF file from the current LaTeX document by pressing Command-B keys in Sublime Text. Under the hood this runs the pdflatex
program that is installed with the MacTeX distribution. On completion Sublime Text shows the results of the build.This setup requires MacTeX distribution, Sublime Text 3 and writing four lines of text.
1) Open Sublime Text 3 and select New Build System... from Tools > Build System menu.
2) A new window will appear in Sublime Text containing the text:
4) Replace it with the following:
These are the Sublime Text build instructions. The cmd
part instructs Sublime Text to run pdflatex
command with the path to the current file. The selector
setting is for using this build method for all '.tex' files when Tools > Build System > Automatic is selected.
5) Notice that we used the following path: /Library/TeX/texbin/pdflatex
. Verify that this path is correct by launching the Terminal app and executing the command
If the output of the command is different, put it in the build file instead of /Library/TeX/texbin/pdflatex
.
Run Command On Sublime Text For Mac Os X
6) Save the build system file with Command-S and name it LaTeX.sublime-build
. The file will be saved to
7) Open Tools > Build System menu. You will see the new LaTeX build system option that we created. Select LaTeX or Automatic option.
Congratulations, the setup is complete!
Run Command On Sublime Text For Mac Os X Terminal
Building a PDF from a LaTeX document
Sublime Text Command Line Install
To create a PDF file from a LaTeX document open it in Sublime Text and press Command-B. This can also be done by selecting the Tools > Build menu item.
When the build is finished Sublime Text will show its results. The build results area can be opened at any time from Tools > Build Results menu and closed with Esc key.
This method was tested on Mac OS X El Capitan with MacTeX-2015 and Sublime Text build 3103.
Viewing a PDF with auto reload
Sublime Text Command Line
Usually as I am writing a LaTeX document in Sublime Text I want to preview the PDF. For that purpose I was first using the Preview app which is pre-installed on OS X. The app works well and reloads the PDF file when it is updated. The problem is that it goes back to the first page of the PDF when it is reloaded and you need to manually scroll back to the current page.
Fortunately, there is another PDF reader app called Skim that reloads PDF without loosing the current reading position. Turn on the 'Check for file changes' setting in its Sync preferences, open your PDF document and it will reload each time you rebuild your LaTeX document from Sublime Text.
Run Command On Sublime Text For Macro Multiple Times
I hope that was useful. If you have any difficulties with the setup please leave a comment below.