For those who use LaTeX to write a paper with LaTexTools, a plugin for sublime text (2 or 3), this article will help make them portable.

Prerequisites

Note: Make sure to download the portable version.

Download tools

Sublime Text 3 (download)

Make sure to install Package Control, after you install sublime text 3.

ImageMagick (download)

The tool that allows us to see previews for equations or figures.

MiKTex (download)

The actual backend tool for building LaTeX files. We can also download plugins for Latex using MikTex.

SumatraPDF (download)

The viewer. SumartraPDF is very light, and it allows us to search selected lines by backward and forward search between the sublime and itself.

Getting Started

1. Installation

folder-structure

Install the downloaded programs. Each program should have its own folder wrapping them.
The figure above shows my folder structure.

2. Setting up Environment Variables

Now, we have to set environment variables for Windows 10.

For the easier setting, here I share the batch files for both addition and restoration of the variables.

Adding the variables

Create a batch file, which I named it as addToPath.bat. Don’t forget to filling it with the right paths for previously installed programs.

del restorePath.txt
echo %path% >> restorePath.txt
setx path "%path%;%~dp0SumatraPDF;%~dp0Sublime Text 3;%~dp0MiKTeX 2.9\texmfs\install\miktex\bin;%~dp0ImageMagick"
setx sublime "%~dp0Sublime Text 3"

PAUSE

If you run the file by double-clicking it, it will automatically add the paths to the environment variable, path, for Windows 10.

Restoring the variables

Don’t worry about restoring to the original condition. With the script below, we can always go back to the original condition. Create a batch file, which I named as restorePath.bat.

set /P restore=<./restorePath.txt
setx path "%restore%"

PAUSE

If you run the file, it will automatically restore the original path.

3. Checking the system

To check all things are in the right place, we need first to run Sublime Text 3. Then, type ctrl+shit+p to open the command palette. In the command palette, type and run LaTexTools: Check system.

  • If everything is appeared to be OK, we are good to go.
  • If there is a problem with the Variable or Program section, your path in addToPath.bat has a problem.
    • Run restorePath.bat, correct the paths in addToPath.bat, and run it again.
  • If there is a problem with Packages for equation preview, you need to install them by running ‘MiKTex’ manually.
    • First, open the MiKTex console and update the plugins.
    • Second, in the Packages tab, search packages that are required and install them.
      • If it fails to install, change the repository. I used mirrors.tuna.tsinghua.edu.cn

4. Backward searching function for SumatraPDF

Before setting up the backward searching function for SumatraPDF, a LaTeX file must be built at least once. After the compilation, in SumatraPDF, navigate to Settings | Options, and type "PATH-TO\sublime_text.exe" "%f:%l" in the text-entry field for inverse-search command line. Or, you can also open cmd.exe and run setx path "%path%;PATH-TO\SumatraPDF"

Note: For me, it is "E:\utils\Portable Sublime with LaTeXTools\Sublime Text 3\sublime_text.exe" "%f:%l"


References

  1. LaTexTools

Leave a comment