ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Beautify​Latex

by ketan ST2/ST3

No description provided

Details

Installs

  • Total 10K
  • Win 5K
  • OS X 3K
  • Linux 2K
Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11
Windows 0 2 4 3 3 7 7 3 4 1 0 2 7 5 5 2 2 2 2 2 4 6 2 1 2 8 7 3 4 4 0 5 3 1 2 4 5 2 2 3 9 3 4 3 3 4
OS X 0 0 0 2 0 1 1 1 1 0 0 3 0 1 2 2 0 0 1 1 0 2 1 2 2 1 1 3 1 0 2 1 1 2 0 1 1 3 4 2 2 1 1 1 0 1
Linux 0 2 0 0 3 2 0 1 0 1 0 1 0 0 2 1 2 0 2 2 2 0 2 0 0 3 1 2 3 2 0 0 2 1 3 2 1 0 2 0 2 0 0 2 2 1

Readme

Source
raw.​githubusercontent.​com

BeautifyLatex

Prettifies latex code using latexindent.pl

Hooks

This package offers a pre-save hook, i.e., your latex files will be reformatted automatically before saving. To activate this feature, set:

"run_on_save": true,

The sublime command “beautify_latex” performs a save after formatting. You can disable this default by setting:

"save_on_beautify": false

You can change the file patterns handled by this plugin in the settings:

"file_patterns": [ "\\.tex"],

Tabs or Spaces

By default, Sublime does not translate tabs to spaces. If you wish to use tabs you will not need to change your settings. If you wish to use spaces, add the following setting.

"translate_tabs_to_spaces": true

Key Binding

ctrl + cmd + k on OS X, or ctrl + alt + k on Windows

Installation

Package Control

This package is a fork of ketan/BeautifyLatex, and the Sublime Text package has not been updated (as of Sep 6 2017). So you have to install the package manually.

Manual Installation

1. Navigate to the Sublime Text package directory “bash cd ”~/Library/Application Support/Sublime Text 2/Packages/“ # OS X (I think) cd "C:\Users<username>\AppData\Roaming\Sublime Text 3\Packages” # (using Windows 10)

**2. Clone this repository**
```bash
  git clone https://github.com/flipphillips/BeautifyLatex.git
  ### Or ###
  git clone git@github.com:flipphillips/BeautifyLatex.git

3. Restart Sublime Text

Note for Mac users

If you are using OS X El Capitan and get the following error

Error: can't specify None for path argument

while saving tex files, you may want to check the following things.

  1. Do you have latexindent? This can be checked by typing which latexindent in the terminal. If you have latexindent installed, you shall get the following message telling you the directory, in which your latexindent resides.

    $ which latexindent
    /Library/TeX/texbin/latexindent
    

If you do not have latexindent at all, you may consider upgrading your MacTeX or install latexindent manually. See CTAN page of latexindent here.

  1. Is your latexindent functional? To check this, go to the terminal, cd to the directory containing your latexindent, and type perl latexindent. If your latexindent is functional, you shall see its version information (see below).

    $ cd /Library/TeX/texbin/
    $ perl latexindent
    latexindent.pl version 2.1R
    usage: latexindent.pl [options] [file][.tex]
          -h  help (see the documentation for detailed instructions and examples)
          -o  output to another file; sample usage
                    latexindent.pl -o myfile.tex outputfile.tex
          -w  overwrite the current file- a backup will be made, but still be careful
          -s  silent mode- no output will be given to the terminal
          -t  tracing mode- verbose information given to the log file
          -l  use localSettings.yaml (assuming it exists in the directory of your file)
          -d  ONLY use defaultSettings.yaml, ignore ALL user files
          -c=cruft directory used to specify the location of backup files and indent.log
    

Otherwise, you will see certain error message saying that YAML::Tiny (or some other components) was missing. To install these components, type the following lines in terminal (you may need to input your admin password).

$ sudo cpan App::cpanminus
    $ sudo cpan YAML::Tiny
    $ sudo perl -MCPAN -e 'install "File::HomeDir"'

After executing the above lines, check the availability of latexindent by typing perl latexindent again in the terminal.

  1. Install Fix Mac Path package and add the following line

    {
      "additional_path_items": ["/Library/TeX/texbin"]
    }
    

in the user settings of BeautifyLatex. The string "/Library/TeX/texbin" is the directory containing your latexindent. Change it accordingly if you have a different directory.

  1. If the problem has been solved, great! Otherwise (I mean you still saw Error: can't specify None for path argument), type the following line in terminal,

    $ sudo ln -s /Library/TeX/texbin/latexindent /Library/TeX/texbin/latexindent.pl
    

which links latexindent.pl to latexindent. (It seems that by default MacTeX does not ship with latexindent.pl.) After linking, BeautifyLatex should run beautifully now.

As a reference, you may want to read this thread on tex.stackexchange.com.