Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increasing support for MiKTeX #1495

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions LaTeXTools.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@

"osx": {
// Path used when invoking tex & friends; MUST include $PATH
"texpath" : "$PATH:/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin"
// For TeXlive 2011 (or other years) use
"texpath" : "$PATH:/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin",
// For MiKTeX
// "texpath" : "$PATH:/usr/local/bin:$HOME/bin",
// TeX distro: "miktex" or "texlive"
"distro" : "texlive"
},


Expand All @@ -237,7 +242,12 @@

"linux" : {
// Path used when invoking tex & friends; MUST include $PATH
// For TeXlive 2011 (or other years) use
"texpath" : "$PATH:/usr/texbin",
// For MiKTeX
// "texpath" : "$PATH:/usr/local/bin:$HOME/bin",
// TeX distro: "miktex" or "texlive"
"distro" : "texlive",
// Command to invoke Python. Useful if you have Python installed in a
// non-standard location or want to use a particular version of python.
// Both Python2 and Python3 are supported, but must have the DBus bindings
Expand Down Expand Up @@ -379,7 +389,8 @@
// people writing their own build engines.
//
// "traditional" replicates the 'old' system based on
// latexmk (TeXLive) / texify (MiKTeX)
// latexmk (TeXLive, MiKTeX) / texify
// (MiKTeX, missing `Perl` interpreter and `latexmk` MiKTeX package)
//
// custom name you can also use third-party build engines;
// if so, set the "builder_path" option below
Expand Down Expand Up @@ -640,4 +651,4 @@
If you use `infinite` the cache will not invalidated automatically.
*/
"local_cache_life_span": "30 m"
}
}
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If you also use prereleases of other packages just add them comma separated into

This plugin provides several features that simplify working with LaTeX files:

* The ST build command takes care of compiling your LaTeX source to PDF using `texify` (Windows/MikTeX) or `latexmk` (OSX/MacTeX, Windows/TeXlive, Linux/TeXlive). Then, it parses the log file and lists errors and warning. Finally, it launches the PDF viewer and, on supported viewers ([Sumatra PDF](http://sumatrapdfreader.org/free-pdf-reader.html) on Windows, [Skim](http://skim-app.sourceforge.net/) on OSX, and [Evince](https://wiki.gnome.org/Apps/Evince) on Linux by default) jumps to the current cursor position.
* The ST build command takes care of compiling your LaTeX source to PDF using `texify` (MikTeX when the `Perl` interpreter and the `latexmk` MiKTeX package are missing) or `latexmk` (OSX/MacTeX, Windows/TeXlive, Linux/TeXlive). Then, it parses the log file and lists errors and warning. Finally, it launches the PDF viewer and, on supported viewers ([Sumatra PDF](http://sumatrapdfreader.org/free-pdf-reader.html) on Windows, [Skim](http://skim-app.sourceforge.net/) on OSX, and [Evince](https://wiki.gnome.org/Apps/Evince) on Linux by default) jumps to the current cursor position.
* Forward and inverse search with the named PDF previewers is fully supported
* Fill everything including references, citations, packages, graphics, figures, etc.
* Plugs into the "Goto anything" facility to make jumping to any section or label in your LaTeX file(s)
Expand Down
25 changes: 12 additions & 13 deletions builders/traditionalBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
from pdfBuilder import PdfBuilder
import shlex

from latextools_utils.perl_latexmk_installed import perl_latexmk_installed
from latextools_utils.distro_utils import using_miktex

DEBUG = False

DEFAULT_COMMAND_LATEXMK = ["latexmk", "-cd", "-f", "-%E",
"-interaction=nonstopmode", "-synctex=1"]

DEFAULT_COMMAND_WINDOWS_MIKTEX = ["texify", "-b", "-p", "--engine=%E",
DEFAULT_COMMAND_MIKTEX_TEXIFY = ["texify", "-b", "-p", "--engine=%E",
"--tex-option=\"--synctex=1\""]


Expand All @@ -36,17 +39,13 @@ def __init__(self, *args):
self.name = "Traditional Builder"
# Display output?
self.display_log = self.builder_settings.get("display_log", False)

# Build command, with reasonable defaults
plat = sublime.platform()
# Figure out which distro we are using
distro = self.platform_settings.get(
"distro",
"miktex" if plat == "windows" else "texlive"
)
if distro in ["miktex", ""]:
default_command = DEFAULT_COMMAND_WINDOWS_MIKTEX
else: # osx, linux, windows/texlive, everything else really!
default_command = DEFAULT_COMMAND_LATEXMK
# osx, linux, windows everything else really!
default_command = DEFAULT_COMMAND_LATEXMK
# When MiKTeX missing perl and latexmk, the `texify` compiler driver will be used.
if using_miktex() and not perl_latexmk_installed():
default_command = DEFAULT_COMMAND_MIKTEX_TEXIFY

self.cmd = self.builder_settings.get("command", default_command)
if isinstance(self.cmd, strbase):
Expand Down Expand Up @@ -136,8 +135,8 @@ def commands(self):

self.display("done.\n")

# This is for debugging purposes
# This is for debugging purposes
if self.display_log:
self.display("\nCommand results:\n")
self.display(self.out)
self.display("\n\n")
self.display("\n\n")
2 changes: 1 addition & 1 deletion docs/available-builders.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

By default, LaTeXTools uses the `traditional` builder, which is designed to work in most circumstances and for most setups. This builder provides all of the builder features discussed elsewhere in the documentation, such as the various [builder features](features.md#default-builder), including multi-document support, the ability to set LaTeX flags via the `TeX Options` settings, etc.

When you are using MiKTeX, the `traditional` builder defaults to using the MiKTeX compiler driver [`texify`](http://docs.miktex.org/manual/texifying.html), which automatically runs PDFLaTeX / XeLaTeX / LuaLaTeX as many times as necessary to generate a document. Note that because of certain limitations of `texify`, some features, such as support for output directory, auxiliary directory, jobname, etc. are unavailable when using the traditional builder. You can change this by installing `latexmk` and changing the `command` setting in the `builder_settings` block to `"latexmk -cd -f -%E -interaction=nonstopmode -synctex=1"`, in which case the `traditional` builder will run `latexmk` instead of `texify`
When you are using MiKTeX and are missing `Perl` interpreter and the `latexmk` MiKTeX package, the `traditional` builder defaults to using the MiKTeX compiler driver [`texify`](http://docs.miktex.org/manual/texifying.html), which automatically runs PDFLaTeX / XeLaTeX / LuaLaTeX as many times as necessary to generate a document. Note that because of certain limitations of `texify`, some features, such as support for output directory, auxiliary directory, jobname, etc. are unavailable when using the traditional builder. You can change this by installing `latexmk` MiKTeX package and a `Perl` interpreter, in which case the `traditional` builder will run `latexmk` instead of `texify`.

When you are using any other setup (MacTeX or TeXLive on Linux or Windows), the `traditional` builder uses [`latexmk`](http://www.ctan.org/pkg/latexmk/), which supports all the documented features for the builder.

Expand Down
4 changes: 2 additions & 2 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ There are three special values that can be used, `<<temp>>` `<<project>>` and `<

**Note**: the `--aux-directory` flag is only implemented by MiKTeX, so the corresponding settings will only be valid if you are using MiKTeX, as indicated by your `distro` setting. To get similar behavior on TeXLive / MacTeX, you can use the `copy_output_on_build` setting described in the [settings section](settings.md#output-directory-settings) with any of the `output_directory` settings. This will run `pdflatex` / `xelatex` / `lualatex` with the `--output-directory` flag and then copy the resulting PDF to the same directory as your main TeX document.

**Note**: These flags can only be set when using `latexmk` (i.e., the `traditional` builder on OS X and Linux), the `basic` builder or the `script` builder (see below [for documentation on using the script builder](available-builders.md#script-builder)). If you are using `texify` (i.e. the `traditional` builder on MiKTeX) or the simple builder, the `output_directory` and `aux_directory` settings will be ignored.
**Note**: These flags can only be set when using `latexmk` (i.e., the `traditional` builder on Windows, OS X and Linux), the `basic` builder or the `script` builder (see below [for documentation on using the script builder](available-builders.md#script-builder)). If you are using `texify` (i.e. the `traditional` builder on MiKTeX) or the simple builder, the `output_directory` and `aux_directory` settings will be ignored.

### Jobname
The `--jobname` flag can be set in several ways:
* Using a TEX directive, such as `%!TEX jobname = <jobname>` near the top of the file.
* Using the [TeX Options](#tex-options) feature to set `--jobname`
* Using the corresponding `jobname` setting detailed in [the settings section](settings.md#output-directory-settings).

**Note**: Jobname can only be set when using `latexmk` (i.e., the `traditional` builder on OS X and Linux), the `basic` builder or the `script` builder (see below [for documentation on using the script builder](available-builders.md#script-builder)). If you are using `texify` (i.e. the `traditional` builder on MiKTeX) or the simple builder, the `jobname` setting wil be ignored.
**Note**: Jobname can only be set when using `latexmk` (i.e., the `traditional` builder on Windows, OS X and Linux), the `basic` builder or the `script` builder (see below [for documentation on using the script builder](available-builders.md#script-builder)). If you are using `texify` (i.e. the `traditional` builder on MiKTeX) or the simple builder, the `jobname` setting wil be ignored.

### Customizing the compilation command
It is possible to customize the command run by setting the `command` option under Builder Settings. See the section on [Builder Settings](settings.md#builder-settings) for details.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

LaTeXTools plugin provides several features that simplify working with LaTeX files:

* The ST build command takes care of compiling your LaTeX source to PDF using `texify` (Windows/MikTeX) or `latexmk` (OSX/MacTeX, Windows/TeXlive, Linux/TeXlive). Then, it parses the log file and lists errors and warning. Finally, it launches the PDF viewer and, on supported viewers ([Sumatra PDF](http://sumatrapdfreader.org/free-pdf-reader.html) on Windows, [Skim](http://skim-app.sourceforge.net/) on OSX, and [Evince](https://wiki.gnome.org/Apps/Evince) on Linux by default) jumps to the current cursor position.
* The ST build command takes care of compiling your LaTeX source to PDF using `texify` (MikTeX when the `Perl` interpreter and the `latexmk` MiKTeX package are missing) or `latexmk` (OSX/MacTeX, Windows/TeXlive, Linux/TeXlive). Then, it parses the log file and lists errors and warning. Finally, it launches the PDF viewer and, on supported viewers ([Sumatra PDF](http://sumatrapdfreader.org/free-pdf-reader.html) on Windows, [Skim](http://skim-app.sourceforge.net/) on OSX, and [Evince](https://wiki.gnome.org/Apps/Evince) on Linux by default) jumps to the current cursor position.
* Forward and inverse search with the named PDF previewers is fully supported
* Fill everything including references, citations, packages, graphics, figures, etc.
* Plugs into the "Goto anything" facility to make jumping to any section or label in your LaTeX file(s)
Expand Down
30 changes: 25 additions & 5 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ If you are running LaTeXTools for the first time, you may want to run the **LaTe

### Distribution

On **OSX**, you need to be running the [MacTeX](https://www.tug.org/mactex/) distribution (which is pretty much the only one available on the Mac anyway). Just download and install it in the usual way. We have tested MacTeX versions 2010--2016, both 32 and 64 bits; these work fine. MacTeX 2008 does *not* seem to work out of the box, so please upgrade.
On **OSX**, both [MacTeX](https://www.tug.org/mactex/) and [MiKTeX](http://www.miktex.org/) (since version 2.9.6300) are supported. Pick one and install it following the relevant documentation. We have tested MacTeX versions 2010--2016, both 32 and 64 bits; these work fine. MacTeX 2008 does *not* seem to work out of the box, so please upgrade. The MiKTeX has recommended to install the latest version.

- MacTeX
If you don't want to install the entire MacTeX distribution—which is pretty big—[BasicTeX](https://www.tug.org/mactex/morepackages.html) will also work, though you may need to spend more time ensuring all the packages you need are installed! One such package that is missing is `latexmk`, which is a script for building LaTeX documents, which LaTeXTools uses by default. You can either choose to install `latexmk` or [change the builder](#builder.md) to use a builder that does not require `latexmk`. To install `latexmk`, you can either use the **TeX Live Utility** (assuming you are using a recent version of BasicTeX) or from the **Terminal** type `sudo tlmgr install latexmk`, which will prompt you for your password and install the `latexmk` package.

- MiKTeX
MiKTeX adopts a rolling update mechanism to always keep up-to-date, and based on the on-the-fly package management mechanism, it asks users if they want to automatically install missing components from the Internet, if required. This allows you to reduce TeX installations as much as possible.

We recommend following the [official guidelines](https://miktex.org/howto/install-miktex-mac) for installation and update, and turn on the auto-install feature. One such package that is missing is `latexmk`, which is a script for building LaTeX documents, which LaTeXTools uses by default. You can either choose to install `latexmk` or [change the builder](#builder.md) to use a builder that does not require `latexmk`. To install `latexmk`, you can either use the **MiKTeX Console** or from the **Terminal** type `sudo mpm --admin --install latexmk` or `mpm --install latexmk`, which will prompt you for your password and install the `latexmk` package.

If you don't want to install the entire MacTeX distribution—which is pretty big—[BasicTeX](https://www.tug.org/mactex/morepackages.html) will also work, though you may need to spend more time ensuring all the packages you need are installed! One such package that is missing is `latexmk`, which is a script for building LaTeX documents, which LaTeXTools uses by default. You can either choose to install `latexmk` or [change the builder](#builder.md) to use a builder that does not require `latexmk`. To install `latexmk`, you can either use the **TeX Live Utility** (assuming you are using a recent version of BasicTeX) or from the **Terminal** type `sudo tlmgr install latexmk`, which will prompt you for your password and install the `latexmk` package.

### Setup Skim

Expand Down Expand Up @@ -77,7 +84,16 @@ Sorry for the complications. It's not my fault.

### Distribution

On **Windows**, both [MiKTeX](http://www.miktex.org/) and [TeXLive](https://www.tug.org/texlive/) are supported. Pick one and install it following the relevant documentation.
On **Windows**, both [MiKTeX](http://miktex.org/) and [TeXLive](https://www.tug.org/texlive/) are supported. Pick one and install it following the relevant documentation.

### Setup Perl

If you are using `latexmk` with MiKTeX, you will need to install both the `latexmk` MiKTeX package and a `Perl` interpreter. We recommend the following Perl distributions:

- [Strawberry Perl](http://strawberryperl.com/)
- [ActiveState Perl](http://www.activestate.com/activeperl/downloads)

First of all, download and install a Perl distribution. Then start the **MiKTeX Console**, and install the `latexmk` package. Make sure the Perl binaries added to your `PATH` system variable or to the `texpath` when setting up LaTeXTools.

### Setup Sumatra

Expand Down Expand Up @@ -136,9 +152,13 @@ Finally, you need to ensure that the `distro` setting is correct. The possible v

### Distribution

You need to install TeXLive.
On **Linux**, both [TeXLive](https://www.tug.org/texlive/) and [MiKTeX](http://miktex.org/) (since version 2.9.6300) are supported.

- TeXLive
We highly recommend installing the version directly from TUG, which can be found [here](https://www.tug.org/texlive/acquire-netinstall.html) rather than the version included with your distribution, as TeXLive is generally updated more regularly and tends to include more features. In particular, if you are on Ubuntu, note that `apt-get install texlive` will get you a working but incomplete setup. For example, it will *not* install `latexmk`, which is essential to LaTeXTools. You need to install it via `apt-get install latexmk`. However, as long as the expected binaries are available on your system, LaTeXTools should generally work.

We highly recommend installing the version directly from TUG, which can be found [here](https://www.tug.org/texlive/acquire-netinstall.html) rather than the version included with your distribution, as TeXLive is generally updated more regularly and tends to include more features. In particular, if you are on Ubuntu, note that `apt-get install texlive` will get you a working but incomplete setup. For example, it will *not* install `latexmk`, which is essential to LaTeXTools. You need to install it via `apt-get install latexmk`. However, as long as the expected binaries are available on your system, LaTeXTools should generally work.
- MiKTeX
We recommend following the [Official Guide](https://miktex.org/download#unx) to install, initialize, update, etc., and turn on automatic installation. One such package that is missing is `latexmk`, which is a script for building LaTeX documents, which LaTeXTools uses by default. You can either choose to install `latexmk` or [change the builder](#builder.md) to use a builder that does not require `latexmk`. To install `latexmk`, you can either use the **MiKTeX Console** or from the **Terminal** type `sudo mpm --admin --install latexmk` or `mpm --install latexmk`, which will prompt you for your password and install the `latexmk` package.

You can use the **LaTeXTools: Check System** command to ensure that the expected binaries are found.

Expand Down
Loading