From 8bb8e0bcd52e45d0ac490a65987d3667d7305616 Mon Sep 17 00:00:00 2001 From: maboloshi Date: Wed, 1 Jul 2020 15:21:39 +0800 Subject: [PATCH 01/13] Add `_get_perl_command()` and `perl_installed()` --- latextools_utils/perl_installed.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 latextools_utils/perl_installed.py diff --git a/latextools_utils/perl_installed.py b/latextools_utils/perl_installed.py new file mode 100644 index 000000000..06170e496 --- /dev/null +++ b/latextools_utils/perl_installed.py @@ -0,0 +1,18 @@ +import os +import sublime + +try: + from latextools_utils.external_command import get_texpath + from latextools_utils.system import which +except ImportError: + from .external_command import get_texpath + from .system import which + +def _get_perl_command(): + texpath = get_texpath() or os.environ['PATH'] + return which('perl', path=texpath) + +def perl_installed(): + """Return whether perl is available in the PATH.""" + return _get_perl_command() is not None + From 06742dd263048a3d2b3555db7817e6e4ee66d3e3 Mon Sep 17 00:00:00 2001 From: maboloshi Date: Wed, 1 Jul 2020 15:41:21 +0800 Subject: [PATCH 02/13] The traditional Builder only use `texify` when Windows/Miktex is missing `Perl` --- builders/traditionalBuilder.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/builders/traditionalBuilder.py b/builders/traditionalBuilder.py index a546b6a09..a19bc30da 100644 --- a/builders/traditionalBuilder.py +++ b/builders/traditionalBuilder.py @@ -12,12 +12,16 @@ from pdfBuilder import PdfBuilder import shlex +if sublime.platform() == 'windows': + from latextools_utils.perl_installed import perl_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_WINDOWS_MIKTEX_TEXIFY = ["texify", "-b", "-p", "--engine=%E", "--tex-option=\"--synctex=1\""] @@ -36,17 +40,14 @@ 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/texlive, miktex(having perl) everything else really! + default_command = DEFAULT_COMMAND_LATEXMK + # When windows/miktex missing perl, the `texify` compiler driver will be used. + if sublime.platform() == 'windows': + if using_miktex() and not perl_installed(): + default_command = DEFAULT_COMMAND_WINDOWS_MIKTEX_TEXIFY self.cmd = self.builder_settings.get("command", default_command) if isinstance(self.cmd, strbase): From 52f0a10597dba6b63bce395206caed805096d787 Mon Sep 17 00:00:00 2001 From: maboloshi Date: Wed, 1 Jul 2020 15:52:50 +0800 Subject: [PATCH 03/13] Add check "perl" and "texify" when Windows/Miktex --- system_check.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system_check.py b/system_check.py index e1e1d8055..6206c5d41 100644 --- a/system_check.py +++ b/system_check.py @@ -454,10 +454,17 @@ def run(self): # a list of programs, each program is either a string or a list # of alternatives (e.g. 32/64 bit version) - programs = [ - 'latexmk' if not self.uses_miktex else 'texify', 'pdflatex', - 'xelatex', 'lualatex', 'biber', 'bibtex', 'bibtex8', 'kpsewhich' - ] + # Add check "perl" and "texify" when Windows/Miktex + if sublime.platform() == 'windows' and self.uses_miktex: + programs = [ + 'latexmk', 'perl', 'texify', 'pdflatex', + 'xelatex', 'lualatex', 'biber', 'bibtex', 'bibtex8', 'kpsewhich' + ] + else: + programs = [ + 'latexmk', 'pdflatex', + 'xelatex', 'lualatex', 'biber', 'bibtex', 'bibtex8', 'kpsewhich' + ] if _HAS_PREVIEW: # ImageMagick requires gs to work with PDFs From c878b37350102dea0657fc04432e193f5402c80f Mon Sep 17 00:00:00 2001 From: maboloshi Date: Wed, 1 Jul 2020 16:57:48 +0800 Subject: [PATCH 04/13] Modify the judgment method used by `texify` Only use `texify` when Windows/Miktex is missing `Perl` --- latextools_utils/output_directory.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/latextools_utils/output_directory.py b/latextools_utils/output_directory.py index f2f720ca2..c511daedc 100644 --- a/latextools_utils/output_directory.py +++ b/latextools_utils/output_directory.py @@ -7,6 +7,7 @@ try: from latextools_utils import get_setting from latextools_utils.distro_utils import using_miktex + from latextools_utils.perl_installed import perl_installed from latextools_utils.tex_directives import ( get_tex_root, parse_tex_directives ) @@ -15,6 +16,7 @@ except ImportError: from . import get_setting from .distro_utils import using_miktex + from .perl_installed import perl_installed from .tex_directives import get_tex_root, parse_tex_directives from .sublime_utils import get_project_file_name from .system import make_dirs @@ -203,10 +205,12 @@ def get_jobname(view_or_root): def using_texify_or_simple(): - if using_miktex(): - builder = get_setting('builder', 'traditional') - if builder in ['', 'default', 'traditional', 'simple']: - return True + builder = get_setting('builder', None) + if (builder == 'simple' or ( + sublime.platform() == 'windows' and + using_miktex() and not perl_installed()) + ): + return True return False From 6291484aa5f0ad17d839269316adb34fc9280108 Mon Sep 17 00:00:00 2001 From: maboloshi Date: Wed, 1 Jul 2020 16:58:41 +0800 Subject: [PATCH 05/13] Modify and the comments that `not supported the Tex Live distro` for `get_aux_directory()` --- latextools_utils/output_directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latextools_utils/output_directory.py b/latextools_utils/output_directory.py index c511daedc..0376ab5eb 100644 --- a/latextools_utils/output_directory.py +++ b/latextools_utils/output_directory.py @@ -44,7 +44,7 @@ class UnsavedFileException(Exception): # return_setting indicates that the raw setting should be returned # as well as the auxiliary directory def get_aux_directory(view_or_root, return_setting=False): - # not supported using texify or the simple builder + # not supported the Tex Live distro or using texify or the simple builder if not using_miktex() or using_texify_or_simple(): if return_setting: return (None, None) From 181d63b8acb691b4923b6e507af7579ef871703f Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Sun, 13 Sep 2020 20:04:35 +0800 Subject: [PATCH 06/13] Merger of judgement conditions --- builders/traditionalBuilder.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builders/traditionalBuilder.py b/builders/traditionalBuilder.py index a19bc30da..ef326427e 100644 --- a/builders/traditionalBuilder.py +++ b/builders/traditionalBuilder.py @@ -45,9 +45,8 @@ def __init__(self, *args): # osx, linux, windows/texlive, miktex(having perl) everything else really! default_command = DEFAULT_COMMAND_LATEXMK # When windows/miktex missing perl, the `texify` compiler driver will be used. - if sublime.platform() == 'windows': - if using_miktex() and not perl_installed(): - default_command = DEFAULT_COMMAND_WINDOWS_MIKTEX_TEXIFY + if sublime.platform() == 'windows' and using_miktex() and not perl_installed(): + default_command = DEFAULT_COMMAND_WINDOWS_MIKTEX_TEXIFY self.cmd = self.builder_settings.get("command", default_command) if isinstance(self.cmd, strbase): From c95c94cceb335b24d28150c3a7ebfd06c1111ca2 Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Sun, 13 Sep 2020 20:05:19 +0800 Subject: [PATCH 07/13] Remove extra spaces --- builders/traditionalBuilder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builders/traditionalBuilder.py b/builders/traditionalBuilder.py index ef326427e..e309f4709 100644 --- a/builders/traditionalBuilder.py +++ b/builders/traditionalBuilder.py @@ -136,8 +136,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") From 0da4d1816f65bae4e7b9548fe18ae21b48ea36ea Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Sun, 13 Sep 2020 20:18:41 +0800 Subject: [PATCH 08/13] Add default `distro` setting to `texlive` for osx and linux. --- LaTeXTools.sublime-settings | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LaTeXTools.sublime-settings b/LaTeXTools.sublime-settings index d18a2f41d..5aae79536 100644 --- a/LaTeXTools.sublime-settings +++ b/LaTeXTools.sublime-settings @@ -207,7 +207,9 @@ "osx": { // Path used when invoking tex & friends; MUST include $PATH - "texpath" : "$PATH:/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin" + "texpath" : "$PATH:/Library/TeX/texbin:/usr/texbin:/usr/local/bin:/opt/local/bin", + // TeX distro: "miktex" or "texlive" + "distro" : "texlive" // Path to PDF viewer, if needed // TODO think about it. Also, maybe configure it here! }, @@ -234,6 +236,8 @@ "linux" : { // Path used when invoking tex & friends; MUST include $PATH "texpath" : "$PATH:/usr/texbin", + // 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 From e26bf1017a0d2ae2cc032c2ad5c92f2d470c00ff Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Tue, 15 Sep 2020 19:57:22 +0800 Subject: [PATCH 09/13] Added MiKTeX related instructions --- docs/available-builders.md | 2 +- docs/install.md | 30 +++++++++++++++++++++++++----- docs/settings.md | 9 +++++---- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/docs/available-builders.md b/docs/available-builders.md index 06e5c3313..24749f719 100644 --- a/docs/available-builders.md +++ b/docs/available-builders.md @@ -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 missing `Perl` interpreter, 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. diff --git a/docs/install.md b/docs/install.md index a4a5deb2f..c2f7e2f35 100644 --- a/docs/install.md +++ b/docs/install.md @@ -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 @@ -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 @@ -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. diff --git a/docs/settings.md b/docs/settings.md index 42bd69bbc..743a6b2ca 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -68,11 +68,12 @@ This section refers to setting that can be found in a platform-specific block fo ### All Platforms + * `distro` (`texlive`): either `miktex` or `texlive` (include MacTeX), depending on your TeX distribution. * `texpath` (varies): the path to TeX & friends. Note that this should always include `$PATH` to ensure the default path is loaded as well. ### Windows - * `distro` (`miktex`): either `miktex` or `texlive`, depending on your TeX distribution + * `distro` (`miktex`): either `miktex` or `texlive`, depending on your TeX distribution. * `sumatra` (`""`): leave blank or omit if the SumatraPDF executable is in your `PATH` and is called `SumatraPDF.exe`, as in a default installation; otherwise, specify the *full path and file name* of the SumatraPDF executable. * `sublime_executable` (`""`): this is used if `keep_focus` is set to true and the path to your sublime_text executable cannot be discovered automatically. It should point to the full path to your executable `sublime_text.exe`. * `keep_focus_delay` (`0.5`): this is used if `keep_focus` is set to true. It controls how long (in seconds) the delay is between the completion of the `jump_to_pdf` command and the attempt to refocus on Sublime Text. This may need to be adjusted depending on your machine or configuration. @@ -99,7 +100,7 @@ This section refers to setting that can be found in a platform-specific block fo **Note:** Since the build system is meant to be fully customizable, if you use a third-party builder (which hopefully will become available!), you need to refer to its documentation. * `builder` (`"traditional"`): the builder you want to use. Possible values: - * `"default"` or `""` or `"traditional"`: this is the standard LaTeXTools builder, which builds the document using `texify` on MiKTeX or `latexmk` on TeXLive or MacTeX. The majority of the documentation is written assuming you are using this builder. + * `"default"` or `""` or `"traditional"`: this is the standard LaTeXTools builder, which builds the document using `texify` on Windows/MiKTeX that is missing `Perl` interpreter, using `latexmk` on MiKTeX or TeXLive (include MacTeX). The majority of the documentation is written assuming you are using this builder. * `"basic"`: invokes `pdflatex` / `xelatex` / `lualatex` to build the document. If the log indicates it is necessary, it then runs `biber` or `bibtex` and then two additional runs of `pdflatex` / `xelatex` / `lualatex`. Mostly supports the same features as the `traditional` builder. * `"script"`: invokes the set of commands specified in the `"script_commands"` setting in the platform-specific part of the `"builder_settings"`. See [the documentation](available-builders.md#script-builder) for details. * `"simple"`: invokes `pdflatex` 1x or 2x as needed, then `bibtex` and `pdflatex` again if needed; intended mainly as a simple example for people writing their own build engines. @@ -111,8 +112,8 @@ This section refers to setting that can be found in a platform-specific block fo For the `default`/`traditional` builder, the following settings are useful: * `program` (unset): one of `pdflatex` (the default), `xelatex` or `lualatex`. This selects the TeX engine. * `command` (unset): the precise `latexmk` or `texify` command to be invoked. This must be a list of strings. The defaults (hardcoded, not shown in the settings file) are: - * (TeXLive): `["latexmk", "-cd", "-e", "-f", "-%E", "-interaction=nonstopmode", "-synctex=1"]` - * (MiKTeX): `["texify", "-b", "-p", "--engine=%E", "--tex-option=\"--synctex=1\""]` + * (MiKTeX and TeXLive): `["latexmk", "-cd", "-e", "-f", "-%E", "-interaction=nonstopmode", "-synctex=1"]` + * (MiKTeX/Windows is missing Perl interpreter): `["texify", "-b", "-p", "--engine=%E", "--tex-option=\"--synctex=1\""]` * `options` (unset): allows you to specify a TeX option, such as `--shell-escape`. This must be a tuple: that is, use `options: ["--shell-escape"]` The `basic` builder also supports the `program` and `options` options. For the script builder, the following setting is **required**: From f17c035a4ac25e7c29a4d53825afd3f86b160209 Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Tue, 15 Sep 2020 20:35:58 +0800 Subject: [PATCH 10/13] Modify `traditional` description for LaTeXTools.sublime-settings --- LaTeXTools.sublime-settings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LaTeXTools.sublime-settings b/LaTeXTools.sublime-settings index 5aae79536..c1968305d 100644 --- a/LaTeXTools.sublime-settings +++ b/LaTeXTools.sublime-settings @@ -379,7 +379,8 @@ // people writing their own build engines. // // "traditional" replicates the 'old' system based on - // latexmk (TeXLive) / texify (MiKTeX) + // latexmk (TeXLive, MiKTeX) / texify + // (MiKTeX/Windows, missing `Perl` interpreter) // // custom name you can also use third-party build engines; // if so, set the "builder_path" option below From 21d9bb099161d2e0c70c5b79d4a54c495ca5de1e Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Tue, 15 Sep 2020 20:38:20 +0800 Subject: [PATCH 11/13] Example of adding "texpath" for MiKTeX --- LaTeXTools.sublime-settings | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/LaTeXTools.sublime-settings b/LaTeXTools.sublime-settings index c1968305d..eaf1d9150 100644 --- a/LaTeXTools.sublime-settings +++ b/LaTeXTools.sublime-settings @@ -207,7 +207,10 @@ "osx": { // Path used when invoking tex & friends; MUST include $PATH + // 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" // Path to PDF viewer, if needed @@ -235,7 +238,10 @@ "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 From d62664212a8ca74cd76ff5d11212eb737bb5143d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=99=E6=BC=A0=E4=B9=8B=E5=AD=90?= <7850715+maboloshi@users.noreply.github.com> Date: Wed, 25 Aug 2021 09:56:44 +0800 Subject: [PATCH 12/13] Update LaTeXTools.sublime-settings --- LaTeXTools.sublime-settings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LaTeXTools.sublime-settings b/LaTeXTools.sublime-settings index 234175365..81d79dedf 100644 --- a/LaTeXTools.sublime-settings +++ b/LaTeXTools.sublime-settings @@ -218,6 +218,7 @@ // For MiKTeX // "texpath" : "$PATH:/usr/local/bin:$HOME/bin", // TeX distro: "miktex" or "texlive" + "distro" : "texlive" }, @@ -650,4 +651,4 @@ If you use `infinite` the cache will not invalidated automatically. */ "local_cache_life_span": "30 m" -} \ No newline at end of file +} From f4568ada5458088d8a531c38d207e88810cc9f05 Mon Sep 17 00:00:00 2001 From: maboloshi <7850715+maboloshi@users.noreply.github.com> Date: Wed, 25 Aug 2021 12:35:58 +0800 Subject: [PATCH 13/13] Fixes and optimizations --- LaTeXTools.sublime-settings | 2 +- README.markdown | 2 +- builders/traditionalBuilder.py | 15 +++++++-------- docs/available-builders.md | 2 +- docs/features.md | 4 ++-- docs/index.md | 2 +- docs/settings.md | 4 ++-- latextools_utils/output_directory.py | 12 +++++------- latextools_utils/perl_installed.py | 18 ------------------ latextools_utils/perl_latexmk_installed.py | 9 +++++++++ system_check.py | 4 ++-- 11 files changed, 31 insertions(+), 43 deletions(-) delete mode 100644 latextools_utils/perl_installed.py create mode 100644 latextools_utils/perl_latexmk_installed.py diff --git a/LaTeXTools.sublime-settings b/LaTeXTools.sublime-settings index 81d79dedf..3e4e2733c 100644 --- a/LaTeXTools.sublime-settings +++ b/LaTeXTools.sublime-settings @@ -390,7 +390,7 @@ // // "traditional" replicates the 'old' system based on // latexmk (TeXLive, MiKTeX) / texify - // (MiKTeX/Windows, missing `Perl` interpreter) + // (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 diff --git a/README.markdown b/README.markdown index 34a3ac9c7..9b194b172 100755 --- a/README.markdown +++ b/README.markdown @@ -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) diff --git a/builders/traditionalBuilder.py b/builders/traditionalBuilder.py index e309f4709..d8f2386df 100644 --- a/builders/traditionalBuilder.py +++ b/builders/traditionalBuilder.py @@ -12,16 +12,15 @@ from pdfBuilder import PdfBuilder import shlex -if sublime.platform() == 'windows': - from latextools_utils.perl_installed import perl_installed - from latextools_utils.distro_utils import using_miktex +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 = ["texify", "-b", "-p", "--engine=%E", +DEFAULT_COMMAND_MIKTEX_TEXIFY = ["texify", "-b", "-p", "--engine=%E", "--tex-option=\"--synctex=1\""] @@ -42,11 +41,11 @@ def __init__(self, *args): self.display_log = self.builder_settings.get("display_log", False) # Build command, with reasonable defaults - # osx, linux, windows/texlive, miktex(having perl) everything else really! + # osx, linux, windows everything else really! default_command = DEFAULT_COMMAND_LATEXMK - # When windows/miktex missing perl, the `texify` compiler driver will be used. - if sublime.platform() == 'windows' and using_miktex() and not perl_installed(): - default_command = DEFAULT_COMMAND_WINDOWS_MIKTEX_TEXIFY + # 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): diff --git a/docs/available-builders.md b/docs/available-builders.md index 1d14ec6f1..30c72df7d 100644 --- a/docs/available-builders.md +++ b/docs/available-builders.md @@ -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 and missing `Perl` interpreter, 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 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. diff --git a/docs/features.md b/docs/features.md index 003033a8c..03903a3a1 100644 --- a/docs/features.md +++ b/docs/features.md @@ -94,7 +94,7 @@ There are three special values that can be used, `<>` `<>` 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: @@ -102,7 +102,7 @@ The `--jobname` flag can be set in several ways: * 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. diff --git a/docs/index.md b/docs/index.md index 45e1fc851..a752c075a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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) diff --git a/docs/settings.md b/docs/settings.md index d34721bf6..dae3486b1 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -101,7 +101,7 @@ This section refers to setting that can be found in a platform-specific block fo **Note:** Since the build system is meant to be fully customizable, if you use a third-party builder (which hopefully will become available!), you need to refer to its documentation. * `builder` (`"traditional"`): the builder you want to use. Possible values: - * `"default"` or `""` or `"traditional"`: this is the standard LaTeXTools builder, which builds the document using `texify` on Windows/MiKTeX that is missing `Perl` interpreter, using `latexmk` on MiKTeX or TeXLive (include MacTeX). The majority of the documentation is written assuming you are using this builder. + * `"default"` or `""` or `"traditional"`: this is the standard LaTeXTools builder, which builds the document using `texify` on MiKTeX that is missing `Perl` interpreter and `latexmk` MiKTeX package, using `latexmk` on MiKTeX or TeXLive (include MacTeX). The majority of the documentation is written assuming you are using this builder. * `"basic"`: invokes `pdflatex` / `xelatex` / `lualatex` to build the document. If the log indicates it is necessary, it then runs `biber` or `bibtex` and then two additional runs of `pdflatex` / `xelatex` / `lualatex`. Mostly supports the same features as the `traditional` builder. * `"script"`: invokes the set of commands specified in the `"script_commands"` setting in the platform-specific part of the `"builder_settings"`. See [the documentation](available-builders.md#script-builder) for details. * `"simple"`: invokes `pdflatex` 1x or 2x as needed, then `bibtex` and `pdflatex` again if needed; intended mainly as a simple example for people writing their own build engines. @@ -114,7 +114,7 @@ This section refers to setting that can be found in a platform-specific block fo * `program` (unset): one of `pdflatex` (the default), `xelatex` or `lualatex`. This selects the TeX engine. * `command` (unset): the precise `latexmk` or `texify` command to be invoked. This must be a list of strings. The defaults (hardcoded, not shown in the settings file) are: * (MiKTeX and TeXLive): `["latexmk", "-cd", "-e", "-f", "-%E", "-interaction=nonstopmode", "-synctex=1"]` - * (MiKTeX/Windows is missing Perl interpreter): `["texify", "-b", "-p", "--engine=%E", "--tex-option=\"--synctex=1\""]` + * (MiKTeX is missing `Perl` interpreter and `latexmk` MiKTeX package): `["texify", "-b", "-p", "--engine=%E", "--tex-option=\"--synctex=1\""]` * `options` (unset): allows you to specify a TeX option, such as `--shell-escape`. This must be a tuple: that is, use `options: ["--shell-escape"]` The `basic` builder also supports the `program` and `options` options. For the script builder, the following setting is **required**: diff --git a/latextools_utils/output_directory.py b/latextools_utils/output_directory.py index 3d4e04004..346cc8bff 100644 --- a/latextools_utils/output_directory.py +++ b/latextools_utils/output_directory.py @@ -6,7 +6,7 @@ from . import get_setting from .distro_utils import using_miktex -from .perl_installed import perl_installed +from .perl_latexmk_installed import perl_latexmk_installed from .tex_directives import get_tex_root, parse_tex_directives from .sublime_utils import get_project_file_name @@ -194,12 +194,10 @@ def get_jobname(view_or_root): def using_texify_or_simple(): - builder = get_setting('builder', None) - if (builder == 'simple' or ( - sublime.platform() == 'windows' and - using_miktex() and not perl_installed()) - ): - return True + if using_miktex(): + builder = get_setting('builder', 'traditional') + if (builder == 'simple' or not perl_latexmk_installed()): + return True return False diff --git a/latextools_utils/perl_installed.py b/latextools_utils/perl_installed.py deleted file mode 100644 index 06170e496..000000000 --- a/latextools_utils/perl_installed.py +++ /dev/null @@ -1,18 +0,0 @@ -import os -import sublime - -try: - from latextools_utils.external_command import get_texpath - from latextools_utils.system import which -except ImportError: - from .external_command import get_texpath - from .system import which - -def _get_perl_command(): - texpath = get_texpath() or os.environ['PATH'] - return which('perl', path=texpath) - -def perl_installed(): - """Return whether perl is available in the PATH.""" - return _get_perl_command() is not None - diff --git a/latextools_utils/perl_latexmk_installed.py b/latextools_utils/perl_latexmk_installed.py new file mode 100644 index 000000000..7a0e57934 --- /dev/null +++ b/latextools_utils/perl_latexmk_installed.py @@ -0,0 +1,9 @@ +import os +from shutil import which +from .external_command import get_texpath + + +def perl_latexmk_installed(): + """Return whether perl and latexmk is available in the PATH.""" + texpath = get_texpath() or os.environ['PATH'] + return which('perl', path=texpath) and which('latexmk', path=texpath) diff --git a/system_check.py b/system_check.py index 589cba622..8feb869c2 100644 --- a/system_check.py +++ b/system_check.py @@ -400,8 +400,8 @@ def run(self): # a list of programs, each program is either a string or a list # of alternatives (e.g. 32/64 bit version) - # Add check "perl" and "texify" when Windows/Miktex - if sublime.platform() == 'windows' and self.uses_miktex: + # Add check "perl" and "latexmk" when Miktex + if self.uses_miktex: programs = [ 'latexmk', 'perl', 'texify', 'pdflatex', 'xelatex', 'lualatex', 'biber', 'bibtex', 'bibtex8', 'kpsewhich'