12. Appendices

12.1. Required Perl modules

If you intend to use latexindent.pl and not one of the supplied standalone executable files (latexindent.exe is available for Windows users without Perl, see Section 3.1.2), then you will need a few standard Perl modules.

If you can run the minimum code in Listing 649 as in

perl helloworld.pl

then you will be able to run latexindent.pl, otherwise you may need to install the missing modules; see Section 12.1.1 and Section 12.1.2.

Listing 649 helloworld.pl
#!/usr/bin/perl

use strict;                         #     |
use warnings;                       #     |
use Encode;                         #     |
use Getopt::Long;                   #     |
use Data::Dumper;                   #  these modules are
use List::Util qw(max);             #  generally part
use PerlIO::encoding;               #  of a default perl distribution
use open ':std', ':encoding(UTF-8)';#     |
use Text::Wrap;                     #     |
use Text::Tabs;                     #     |
use FindBin;                        #     |
use File::Copy;                     #     |
use File::Basename;                 #     |
use File::HomeDir;                  # <--- typically requires install via cpanm
use YAML::Tiny;                     # <--- typically requires install via cpanm

print "hello world";
exit;

12.1.1. Module installer script

latexindent.pl ships with a helper script that will install any missing perl modules on your system; if you run

perl latexindent-module-installer.pl

or

perl latexindent-module-installer.pl

then, once you have answered Y, the appropriate modules will be installed onto your distribution.

12.1.2. Manually installing modules

Manually installing the modules given in Listing 649 will vary depending on your operating system and Perl distribution.

12.1.3. Linux

12.1.3.1. perlbrew

Linux users may be interested in exploring Perlbrew (“Perlbrew” n.d.); an example installation would be:

sudo apt-get install perlbrew
perlbrew init
perlbrew install perl-5.34.0
perlbrew switch perl-5.34.0
sudo apt-get install curl
curl -L http://cpanmin.us | perl - App::cpanminus
cpanm YAML::Tiny
cpanm File::HomeDir

12.1.3.2. Ubuntu/Debian

For other distributions, the Ubuntu/Debian approach may work as follows

sudo apt install perl
sudo cpan -i App::cpanminus
sudo cpanm YAML::Tiny
sudo cpanm File::HomeDir

or else by running, for example,

sudo perl -MCPAN -e'install "File::HomeDir"'

12.1.3.3. Ubuntu: using the texlive from apt-get

Ubuntu users that install texlive using apt-get as in the following

sudo apt install texlive
sudo apt install texlive-latex-recommended

may need the following additional command to work with latexindent.pl

sudo apt install texlive-extra-utils

12.1.3.4. Ubuntu: users without perl

latexindent-linux is a standalone executable for Ubuntu Linux (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system. It is available from (“Home of Latexindent.pl” n.d.).

12.1.3.5. Arch-based distributions

First install the dependencies

sudo pacman -S perl cpanminus

In addition, install perl-file-homedir from AUR, using your AUR helper of choice,

sudo paru -S perl-file-homedir

then run the latexindent-module-installer.pl file located at helper-scripts/

12.1.3.6. Alpine

If you are using Alpine, some Perl modules are not build-compatible with Alpine, but replacements are available through apk. For example, you might use the commands given in Listing 650; thanks to (J. 2020) for providing these details.

Listing 650 alpine-install.sh
# Installing perl
apk --no-cache add miniperl perl-utils

# Installing incompatible latexindent perl dependencies via apk
apk --no-cache add \
    perl-log-dispatch \
    perl-namespace-autoclean \
    perl-specio \
    perl-unicode-linebreak

# Installing remaining latexindent perl dependencies via cpan
apk --no-cache add curl wget make
ls /usr/share/texmf-dist/scripts/latexindent
cd /usr/local/bin && \
    curl -L https://cpanmin.us/ -o cpanm && \
    chmod +x cpanm
cpanm -n App::cpanminus
cpanm -n File::HomeDir
cpanm -n Params::ValidationCompiler
cpanm -n YAML::Tiny

Users of NixOS might like to see https://github.com/cmhughes/latexindent.pl/issues/222 for tips.

12.1.4. Mac

Users of the Macintosh operating system might like to explore the following commands, for example:

brew install perl
brew install cpanm

cpanm YAML::Tiny
cpanm File::HomeDir

Alternatively,

brew install latexindent

latexindent-macos is a standalone executable for macOS (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system. It is available from (“Home of Latexindent.pl” n.d.).

12.1.5. Windows

Strawberry Perl users on Windows might use CPAN client. All of the modules are readily available on CPAN (“CPAN: Comprehensive Perl Archive Network” n.d.). indent.log will contain details of the location of the Perl modules on your system.

latexindent.exe is a standalone executable for Windows (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system; if you wish to see where they are cached, use the trace option, e.g

latexindent.exe -t myfile.tex

12.1.6. The GCString switch

If you find that the lookForAlignDelims (as in Section 5.5) does not work correctly for your language, then you may wish to use the Unicode::GCString module .

This can be loaded by calling latexindent.pl with the GCString switch as in

latexindent.pl --GCString myfile.tex

In this case, you will need to have the Unicode::GCString installed in your perl distribution by using, for example,

cpanm Unicode::GCString

Note: this switch does nothing for latexindent.exe which loads the module by default. Users of latexindent.exe should not see any difference in behaviour whether they use this switch or not, as latexindent.exe loads the Unicode::GCString module.

12.2. Updating the path variable

latexindent.pl has a few scripts (available at (“Home of Latexindent.pl” n.d.)) that can update the path variables. Thank you to (Juang 2015) for this feature. If you’re on a Linux or Mac machine, then you’ll want CMakeLists.txt from (“Home of Latexindent.pl” n.d.).

12.2.1. Add to path for Linux

To add latexindent.pl to the path for Linux, follow these steps:

  1. download latexindent.pl and its associated modules, defaultSettings.yaml, to your chosen directory from (“Home of Latexindent.pl” n.d.) ;

  2. within your directory, create a directory called path-helper-files and download CMakeLists.txt and cmake_uninstall.cmake.in from (“Home of Latexindent.pl” n.d.)/path-helper-files to this directory;

  3. run

    ls /usr/local/bin
    

    to see what is currently in there;

  4. run the following commands

    sudo apt-get update
    sudo apt-get install --no-install-recommends cmake make # or any other generator
    mkdir build && cd build
    cmake ../path-helper-files
    sudo make install
    
  5. run

    ls /usr/local/bin
    

    again to check that latexindent.pl, its modules and defaultSettings.yaml have been added.

To remove the files, run

sudo make uninstall

12.2.2. Add to path for Windows

To add latexindent.exe to the path for Windows, follow these steps:

  1. download latexindent.exe, defaultSettings.yaml, add-to-path.bat from (“Home of Latexindent.pl” n.d.) to your chosen directory;

  2. open a command prompt and run the following command to see what is currently in your %path% variable;

    echo %path%
    
  3. right click on add-to-path.bat and Run as administrator;

  4. log out, and log back in;

  5. open a command prompt and run

    echo %path%
    

    to check that the appropriate directory has been added to your %path%.

To remove the directory from your %path%, run remove-from-path.bat as administrator.

12.3. Batches of files

You can instruct latexindent.pl to operate on multiple files. For example, the following calls are all valid

latexindent.pl myfile1.tex
latexindent.pl myfile1.tex myfile2.tex
latexindent.pl myfile*.tex

We note the following features of the script in relation to the switches detailed in Section 3.

12.3.1. location of indent.log

If the -c switch is not active, then indent.log goes to the directory of the final file called.

If the -c switch is active, then indent.log goes to the specified directory.

12.3.2. interaction with -w switch

If the -w switch is active, as in

latexindent.pl -w myfile*.tex

then files will be overwritten individually. Back-up files can be re-directed via the -c switch.

12.3.3. interaction with -o switch

If latexindent.pl is called using the -o switch as in

latexindent.pl myfile*.tex -o=my-output-file.tex

and there are multiple files to operate upon, then the -o switch is ignored because there is only one output file specified.

More generally, if the -o switch does not have a + symbol at the beginning, then the -o switch will be ignored, and is turned it off.

For example

latexindent.pl myfile*.tex -o=+myfile

will work fine because each .tex file will output to <basename>myfile.tex

Similarly,

latexindent.pl myfile*.tex -o=++

will work because the ‘existence check/incrementation’ routine will be applied.

12.3.4. interaction with lines switch

This behaves as expected by attempting to operate on the line numbers specified for each file. See the examples in Section 8.

12.3.5. interaction with check switches

The exit codes for latexindent.pl are given in Table 1.

When operating on multiple files with the check switch active, as in

latexindent.pl myfile*.tex --check

then

  • exit code 0 means that the text from none of the files has been changed;

  • exit code 1 means that the text from at least one of the files been file changed.

The interaction with checkv switch is as in the check switch, but with verbose output.

12.3.6. when a file does not exist

What happens if one of the files can not be operated upon?

  • if at least one of the files does not exist and latexindent.pl has been called to act upon multiple files, then the exit code is 3; note that latexindent.pl will try to operate on each file that it is called upon, and will not exit with a fatal message in this case;

  • if at least one of the files can not be read and latexindent.pl has been called to act upon multiple files, then the exit code is 4; note that latexindent.pl will try to operate on each file that it is called upon, and will not exit with a fatal message in this case;

  • if latexindent.pl has been told to operate on multiple files, and some do not exist and some cannot be read, then the exit code will be either 3 or 4, depending upon which it scenario it encountered most recently.

12.4. latexindent-yaml-schema.json

latexindent.pl ships with latexindent-yaml-schema.json which might help you when constructing your YAML files.

12.4.1. VSCode demonstration

To use latexindent-yaml-schema.json with VSCode, you can use the following steps:

  1. download latexindent-yaml-schema.json from the documentation folder of (“Home of Latexindent.pl” n.d.), save it in whichever directory you would like, noting it for reference;

  2. following the instructions from (“How to Create Your Own Auto-Completion for Json and Yaml Files on Vs Code with the Help of Json Schema” n.d.), for example, you should install the VSCode YAML extension (“VSCode Yaml Extension” n.d.);

  3. set up your settings.json file using the directory you saved the file by adapting Listing 651; on my Ubuntu laptop this file lives at /home/cmhughes/.config/Code/User/settings.json.

Listing 651 settings.json
{
  "yaml.schemas": {
    "/home/cmhughes/projects/latexindent/documentation/latexindent-yaml-schema.json": "/home/cmhughes/projects/latexindent/defaultSettings.yaml"
  },
  "redhat.telemetry.enabled": true
}

Alternatively, if you would prefer not to download the json file, you might be able to use an adapted version of Listing 652.

Listing 652 settings-alt.json
{
  "yaml.schemas": {
    "https://raw.githubusercontent.com/cmhughes/latexindent.pl/main/documentation/latexindent-yaml-schema.json": "/home/cmhughes/projects/latexindent/defaultSettings.yaml"
  }
}

Finally, if your TeX distribution is up to date, then latexindent-yaml-schema.json should be in the documentation folder of your installation, so an adapted version of Listing 653 may work.

Listing 653 settings-alt1.json
{
  "yaml.schemas": {
    "/usr/local/texlive/2021/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json": "/home/cmhughes/projects/latexindent/defaultSettings.yaml"
  }
}

If you have details of how to implement this schema in other editors, please feel encouraged to contribute to this documentation.

12.5. Using conda

If you use conda you’ll only need

conda install latexindent.pl -c conda-forge

This will install the executable and all its dependencies (including perl) in the activate environment. You don’t even have to worry about defaultSettings.yaml as it included too, you can thus skip Section 12.1 and Section 12.2.

You can get a conda installation for example from (“Conda Forge” n.d.) or from (“Anacoda” n.d.).

12.5.1. Sample conda installation on Ubuntu

On Ubuntu I followed the 64-bit installation instructions at (“How to Install Anaconda on Ubuntu?” n.d.) and then I ran the following commands:

conda create -n latexindent.pl
conda activate latexindent.pl
conda install latexindent.pl -c conda-forge
conda info --envs
conda list
conda run latexindent.pl -vv

I found the details given at (“Solving Environment: Failed with Initial Frozen Solve. Retrying with Flexible Solve.” n.d.) to be helpful.

12.6. Using docker

If you use docker you’ll only need

docker pull ghcr.io/cmhughes/latexindent.pl

This will download the image packed latexindent’s executable and its all dependencies.

Thank you to (eggplants 2022) for contributing this feature; see also (“Latexindent.pl Ghcr (Github Container Repository) Location” n.d.). For reference, ghcr stands for GitHub Container Repository.

12.6.1. Sample docker installation on Ubuntu

To pull the image and show latexindent’s help on Ubuntu:

Listing 654 docker-install.sh
# setup docker if not already installed
if ! command -v docker &> /dev/null; then
  sudo apt install docker.io -y
  sudo groupadd docker
  sudo gpasswd -a "$USER" docker
  sudo systemctl restart docker
fi

# download image and execute
docker pull ghcr.io/cmhughes/latexindent.pl
docker run ghcr.io/cmhughes/latexindent.pl -h

12.6.2. How to format on Docker

When you use latexindent with the docker image, you have to mount target tex file like this:

docker run -v /path/to/local/myfile.tex:/myfile.tex ghcr.io/cmhughes/latexindent.pl -s -w myfile.tex

12.7. pre-commit

Users of .git may be interested in exploring the pre-commit tool (“Pre-Commit: A Framework for Managing and Maintaining Multi-Language Pre-Commit Hooks.” n.d.), which is supported by latexindent.pl. Thank you to (Geus 2022) for contributing this feature, and to (Holthuis 2022) for their contribution to it.

To use the pre-commit tool, you will need to install pre-commit; sample instructions for Ubuntu are given in Section 12.7.1. Once installed, there are two ways to use pre-commit: using CPAN or using conda, detailed in Section 12.7.3 and Section 12.7.4 respectively.

12.7.1. Sample pre-commit installation on Ubuntu

On Ubuntu I ran the following command:

python3 -m pip install pre-commit

I then updated my path via .bashrc so that it includes the line in Listing 655.

Listing 655 .bashrc update
...
export PATH=$PATH:/home/cmhughes/.local/bin

12.7.2. pre-commit defaults

The default values that are employed by pre-commit are shown in Listing 656.

Listing 656 .pre-commit-hooks.yaml (default)
- id: latexindent
  name: latexindent.pl
  description: Run latexindent.pl (get dependencies using CPAN)
  minimum_pre_commit_version: 2.1.0
  entry: latexindent.pl
  args: ["--overwriteIfDifferent", "--silent", "--local"]
  language: perl
  types: [tex]
- id: latexindent-conda
  name: latexindent.pl
  description: Run latexindent.pl (get dependencies using Conda)
  minimum_pre_commit_version: 2.1.0
  entry: latexindent.pl
  args: ["--overwriteIfDifferent", "--silent", "--local"]
  language: conda
  types: [tex]
- id: latexindent-docker
  name: latexindent.pl
  description: Run latexindent.pl (get dependencies using Docker)
  minimum_pre_commit_version: 2.1.0
  entry: ghcr.io/cmhughes/latexindent.pl
  language: docker_image
  types: [tex]
  args: ["--overwriteIfDifferent", "--silent", "--local"]

In particular, the decision has deliberately been made (in collaboration with (Holthuis 2022)) to have the default to employ the following switches: overwriteIfDifferent, silent, local; this is detailed in the lines that specify args in Listing 656.

Warning

Users of pre-commit will, by default, have the overwriteIfDifferent switch employed. It is assumed that such users have version control in place, and are intending to overwrite their files.

12.7.3. pre-commit using CPAN

To use latexindent.pl with pre-commit, create the file .pre-commit-config.yaml given in Listing 657 in your git-repository.

Listing 657 .pre-commit-config.yaml (cpan)
- repo: https://github.com/cmhughes/latexindent.pl
  rev: V3.20.6
  hooks:
  - id: latexindent
    args: [-s]

Once created, you should then be able to run the following command:

pre-commit run --all-files

A few notes about Listing 657:

  • the settings given in Listing 657 instruct pre-commit to use CPAN to get dependencies;

  • this requires pre-commit and perl to be installed on your system;

  • the args lists selected command-line options; the settings in Listing 657 are equivalent to calling

    latexindent.pl -s myfile.tex
    

    for each .tex file in your repository;

  • to instruct latexindent.pl to overwrite the files in your repository, then you can update Listing 657 so that args: [-s, -w].

Naturally you can add options, or omit -s and -w, according to your preference.

12.7.4. pre-commit using conda

You can also rely on conda (detailed in Section 12.5) instead of CPAN for all dependencies, including latexindent.pl itself.

Listing 658 .pre-commit-config.yaml (conda)
- repo: https://github.com/cmhughes/latexindent.pl
  rev: V3.20.6
  hooks:
  - id: latexindent-conda
    args: [-s]

Once created, you should then be able to run the following command:

pre-commit run --all-files

A few notes about Listing 657:

  • the settings given in Listing 658 instruct pre-commit to use conda to get dependencies;

  • this requires pre-commit and conda to be installed on your system;

  • the args lists selected command-line options; the settings in Listing 657 are equivalent to calling

    conda run latexindent.pl -s myfile.tex
    

    for each .tex file in your repository;

  • to instruct latexindent.pl to overwrite the files in your repository, then you can update Listing 657 so that args: [-s, -w].

12.7.5. pre-commit using docker

You can also rely on docker (detailed in Section 12.6) instead of CPAN for all dependencies, including latexindent.pl itself.

Listing 659 .pre-commit-config.yaml (docker)
- repo: https://github.com/cmhughes/latexindent.pl
  rev: V3.20.6
  hooks:
    - id: latexindent-docker
      args: [-s]

Once created, you should then be able to run the following command:

pre-commit run --all-files

A few notes about Listing 657:

  • the settings given in Listing 659 instruct pre-commit to use docker to get dependencies;

  • this requires pre-commit and docker to be installed on your system;

  • the args lists selected command-line options; the settings in Listing 657 are equivalent to calling

    docker run -v /path/to/myfile.tex:/myfile.tex ghcr.io/cmhughes/latexindent.pl -s myfile.tex
    

    for each .tex file in your repository;

  • to instruct latexindent.pl to overwrite the files in your repository, then you can update Listing 657 so that args: [-s, -w].

12.7.6. pre-commit example using -l, -m switches

Let’s consider a small example, with local latexindent.pl settings in .latexindent.yaml.

Example 164

We use the local settings given in Listing 660.

Listing 660 .latexindent.yaml
onlyOneBackUp: 1

modifyLineBreaks:
 oneSentencePerLine:
   manipulateSentences: 1

and .pre-commit-config.yaml as in Listing 661:

Listing 661 .pre-commit-config.yaml (demo)
- repo: https://github.com/cmhughes/latexindent.pl
  rev: V3.20.6
  hooks:
  - id: latexindent
    args: [-l, -m, -s, -w]

Now running

pre-commit run --all-files

is equivalent to running

latexindent.pl -l -m -s -w myfile.tex

for each .tex file in your repository.

A few notes about Listing 661:

  • the -l option was added to use the local .latexindent.yaml (where it was specified to only create one back-up file, as git typically takes care of this when you use pre-commit);

  • -m to modify line breaks; in addition to -s to suppress command-line output, and -w to format files in place.

12.8. indentconfig options

This section describes the possible locations for the main configuration file, discussed in Section 4. Thank you to (Nehctargl 2022) for this contribution. The possible locations of indentconfig.yaml are read one after the other, and reading stops when a valid file is found in one of the paths.

Before stating the list, we give summarise in Table 5.

Table 5 indentconfig environment variable summaries

environment variable

type

Linux

macOS

Windows

LATEXINDENT_CONFIG

full path to file

yes

yes

yes

XDG_CONFIG_HOME

directory path

yes

no

no

LOCALAPPDATA

directory path

no

no

yes

The following list shows the checked options and is sorted by their respective priority. It uses capitalized and with a dollar symbol prefixed names (e.g. $LATEXINDENT_CONFIG) to symbolize environment variables. In addition to that the variable name $homeDir is used to symbolize your home directory.

  1. The value of the environment variable $LATEXINDENT_CONFIG is treated as highest priority source for the path to the configuration file.

  2. The next options are dependent on your operating system:

    • Linux:

      1. The file at $XDG_CONFIG_HOME/latexindent/indentconfig.yaml

      2. The file at $homeDir/.config/latexindent/indentconfig.yaml

    • Windows:

      1. The file at $LOCALAPPDATA\latexindent\indentconfig.yaml

      2. The file at $homeDir\AppData\Local\latexindent\indentconfig.yaml

    • Mac:

      1. The file at $homeDir/Library/Preferences/latexindent/indentconfig.yaml

  3. The file at $homeDir/indentconfig.yaml

  4. The file at $homeDir/.indentconfig.yaml

12.8.1. Why to change the configuration location

This is mostly a question about what you prefer, some like to put all their configuration files in their home directory (see $homeDir above), whilst some like to sort their configuration. And if you don’t care about it, you can just continue using the same defaults.

12.8.2. How to change the configuration location

This depends on your preferred location, if, for example, you would like to set a custom location, you would have to change the $LATEXINDENT_CONFIG environment variable.

Although the following example only covers $LATEXINDENT_CONFIG, the same process can be applied to $XDG_CONFIG_HOME or $LOCALAPPDATA because both are environment variables. You just have to change the path to your chosen configuration directory (e.g. $homeDir/.config or $homeDir\AppData\Local on Linux or Windows respectively)

12.8.3. Linux

To change $LATEXINDENT_CONFIG on Linux you can run the following command in a terminal after changing the path:

echo 'export LATEXINDENT_CONFIG="/home/cmh/latexindent-config.yaml"' >> ~/.profile

Context: This command adds the given line to your .profile file (which is commonly stored in $HOME/.profile). All commands in this file a run after login, so the environment variable will be set after your next login.

You can check the value of $LATEXINDENT_CONFIG by typing

echo $LATEXINDENT_CONFIG
/home/cmh/latexindent-config.yaml

Linux users interested in $XDG_CONFIG_HOME can explore variations of the following commands

echo $XDG_CONFIG_HOME
echo ${XDG_CONFIG_HOME:=$HOME/.config}
echo $XDG_CONFIG_HOME
mkdir /home/cmh/.config/latexindent
touch /home/cmh/.config/latexindent/indentconfig.yaml

12.8.4. Windows

To change $LATEXINDENT_CONFIG on Windows you can run the following command in powershell.exe after changing the path:

[Environment]::SetEnvironmentVariable
    ("LATEXINDENT_CONFIG", "\your\config\path", "User")

This sets the environment variable for every user session.

12.8.5. Mac

To change $LATEXINDENT_CONFIG on macOS you can run the following command in a terminal after changing the path:

echo 'export LATEXINDENT_CONFIG="/your/config/path"' >> ~/.profile

Context: This command adds the line to your .profile file (which is commonly stored in $HOME/.profile). All commands in this file a run after login, so the environment variable will be set after your next login.

12.9. logFilePreferences

Listing 53 describes the options for customising the information given to the log file, and we provide a few demonstrations here.

Example 165

Let’s say that we start with the code given in Listing 662, and the settings specified in Listing 663.

Listing 662 simple.tex
\begin{myenv}
  body of myenv
\end{myenv}
Listing 663 logfile-prefs1.yaml
logFilePreferences:
    showDecorationStartCodeBlockTrace: "+++++"
    showDecorationFinishCodeBlockTrace: "-----"

If we run the following command (noting that -t is active)

latexindent.pl -t -l=logfile-prefs1.yaml simple.tex

then on inspection of indent.log we will find the snippet given in Listing 664.

Listing 664 indent.log
       +++++
TRACE: environment found: myenv
       No ancestors found for myenv
       Storing settings for myenvenvironments
       indentRulesGlobal specified (0) for environments, ...
       Using defaultIndent for myenv
       Putting linebreak after replacementText for myenv
       looking for COMMANDS and key ={value}
TRACE: Searching for commands with optional and/or mandatory arguments AND key ={value}
       looking for SPECIAL begin/end
TRACE: Searching myenv for special begin/end (see specialBeginEnd)
TRACE: Searching myenv for optional and mandatory arguments
       ... no arguments found
       -----

Notice that the information given about myenv is ‘framed’ using +++++ and ----- respectively.

12.10. Encoding indentconfig.yaml

In relation to Section 4, Windows users that encounter encoding issues with indentconfig.yaml, may wish to run the following command in either cmd.exe or powershell.exe:

chcp

They may receive the following result

Active code page: 936

and can then use the settings given in Listing 665 within their indentconfig.yaml, where 936 is the result of the chcp command.

Listing 665 encoding demonstration for indentconfig.yaml
encoding: cp936

12.11. dos2unix linebreak adjustment

dos2unixlinebreaks:integer

If you use latexindent.pl on a dos-based Windows file on Linux then you may find that trailing horizontal space is not removed as you hope.

In such a case, you may wish to try setting dos2unixlinebreaks to 1 and employing, for example, the following command.

latexindent.pl -y="dos2unixlinebreaks:1" myfile.tex

See (“Windows Line Breaks on Linux Prevent Removal of White Space from End of Line” n.d.) for further dertails.

12.12. Differences from Version 2.2 to 3.0

There are a few (small) changes to the interface when comparing Version 2.2 to Version 3.0. Explicitly, in previous versions you might have run, for example,

latexindent.pl -o myfile.tex outputfile.tex

whereas in Version 3.0 you would run any of the following, for example,

latexindent.pl -o=outputfile.tex myfile.tex
latexindent.pl -o outputfile.tex myfile.tex
latexindent.pl myfile.tex -o outputfile.tex
latexindent.pl myfile.tex -o=outputfile.tex
latexindent.pl myfile.tex -outputfile=outputfile.tex
latexindent.pl myfile.tex -outputfile outputfile.tex

noting that the output file is given next to the -o switch.

The fields given in Listing 666 are obsolete from Version 3.0 onwards.

Listing 666 Obsolete YAML fields from Version 3.0
alwaysLookforSplitBrackets
alwaysLookforSplitBrackets
checkunmatched
checkunmatchedELSE
checkunmatchedbracket
constructIfElseFi

There is a slight difference when specifying indentation after headings; specifically, we now write indentAfterThisHeading instead of indent. See Listing 667 and Listing 668

Listing 667 indentAfterThisHeading in Version 2.2
indentAfterHeadings:
    part:
       indent: 0
       level: 1
Listing 668 indentAfterThisHeading in Version 3.0
indentAfterHeadings:
    part:
       indentAfterThisHeading: 0
       level: 1

To specify noAdditionalIndent for display-math environments in Version 2.2, you would write YAML as in Listing 669; as of Version 3.0, you would write YAML as in Listing 670 or, if you’re using -m switch, Listing 671.

Listing 669 noAdditionalIndent in Version 2.2
noAdditionalIndent:
    \[: 0
    \]: 0
Listing 670 noAdditionalIndent for displayMath in Version 3.0
specialBeginEnd:
    displayMath:
        begin: '\\\['
        end: '\\\]'
        lookForThis: 0
Listing 671 noAdditionalIndent for displayMath in Version 3.0
noAdditionalIndent:
    displayMath: 1

“Anacoda.” n.d. Accessed December 22, 2021. https://www.anaconda.com/products/individual.

“Conda Forge.” n.d. Accessed December 22, 2021. https://github.com/conda-forge/miniforge.

“CPAN: Comprehensive Perl Archive Network.” n.d. Accessed January 23, 2017. http://www.cpan.org/.

eggplants. 2022. “Add Dockerfile and Its Updater/Releaser.” June 12, 2022. https://github.com/cmhughes/latexindent.pl/pull/370.

Geus, Tom de. 2022. “Adding Perl Installation + Pre-Commit Hook.” January 21, 2022. https://github.com/cmhughes/latexindent.pl/pull/322.

Holthuis, Jan. 2022. “Fix Pre-Commit Usage.” March 31, 2022. https://github.com/cmhughes/latexindent.pl/pull/354.

“Home of Latexindent.pl.” n.d. Accessed January 23, 2017. https://github.com/cmhughes/latexindent.pl.

“How to Create Your Own Auto-Completion for Json and Yaml Files on Vs Code with the Help of Json Schema.” n.d. Accessed January 1, 2022. https://dev.to/brpaz/how-to-create-your-own-auto-completion-for-json-and-yaml-files-on-vs-code-with-the-help-of-json-schema-k1i.

“How to Install Anaconda on Ubuntu?” n.d. Accessed January 21, 2022. https://askubuntu.com/questions/505919/how-to-install-anaconda-on-ubuntu.

J., Randolf. 2020. “Alpine-Linux Instructions.” August 10, 2020. https://github.com/cmhughes/latexindent.pl/pull/214.

Juang, Jason. 2015. “Add in Path Installation.” November 24, 2015. https://github.com/cmhughes/latexindent.pl/pull/38.

“Latexindent.pl Ghcr (Github Container Repository) Location.” n.d. Accessed June 12, 2022. https://github.com/cmhughes?tab=packages.

Nehctargl. 2022. “Added Support for the Xdg Specification.” December 23, 2022. https://github.com/cmhughes/latexindent.pl/pull/397.

“Perlbrew.” n.d. Accessed January 23, 2017. http://perlbrew.pl/.

“Pre-Commit: A Framework for Managing and Maintaining Multi-Language Pre-Commit Hooks.” n.d. Accessed January 8, 2022. https://pre-commit.com/.

“Solving Environment: Failed with Initial Frozen Solve. Retrying with Flexible Solve.” n.d. Accessed January 21, 2022. https://github.com/conda/conda/issues/9367#issuecomment-558863143.

“VSCode Yaml Extension.” n.d. Accessed January 1, 2022. https://marketplace.visualstudio.com/items?itemName = redhat.vscode-yaml.

“Windows Line Breaks on Linux Prevent Removal of White Space from End of Line.” n.d. Accessed June 18, 2021. https://github.com/cmhughes/latexindent.pl/issues/256.