latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.

GPL-3.0 License

Downloads
462
Stars
833
Committers
38

Bot releases are hidden (Show)

latexindent.pl - V3.23

Published by cmhughes about 1 year ago

  • new feature for oneSentencePerLine: sentencesDoNOTcontain, see issue-419
  • bug fix for items, see issue-467
latexindent.pl - V3.10.1

Published by cmhughes about 3 years ago

changes to defaults:

  • textWrap: Huge now set to overflow by default; this means that words and other strings of characters will not be broken mid-word by the text wrapping routine. Users are encouraged not to change this, but have the option to do so.

enhancements:

example: issue 85

from https://github.com/cmhughes/latexindent.pl/issues/85 starting with

\matrix {
c01 & c02 \\
c_{11} & c12 \\
}

gives, by default

\matrix {
	c01    & c02 \\
	c_{11} & c12 \\
}

example: issue 162

from https://github.com/cmhughes/latexindent.pl/issues/162 starting with

\begin{align}
A & =\begin{array}{cc}
BBB & CCC\\
E & F
\end{array}\\
Z & =\begin{array}{cc}
Y & X\\
W & V
\end{array}
\end{align}

gives, by default,

\begin{align}
	A & =\begin{array}{cc}
		     BBB & CCC \\
		     E   & F
	     \end{array} \\
	Z & =\begin{array}{cc}
		     Y & X \\
		     W & V
	     \end{array}
\end{align}

example: issue 212

from https://github.com/cmhughes/latexindent.pl/issues/212 starting with

\begin{equation}
    \begin{aligned}
        x =& x^2 \mqty[a_{11}  & a_{12} \\ a_{21} & a_{22}] =& f(x) \\
        y =& f(y) =& y^2 \\
        z =& f(z) =& z^2
    \end{aligned}
\end{equation}

gives, by default,

\begin{equation}
	\begin{aligned}
		x = & x^2 \mqty[a_{11} & a_{12} \\ a_{21} & a_{22}] =& f(x) \\
		y = & f(y) =           & y^2    \\
		z = & f(z) =           & z^2
	\end{aligned}
\end{equation}

example: issue 251

from https://github.com/cmhughes/latexindent.pl/issues/251 starting with

\begin{tabular}{ll}
  Testing & Line 1                        \\
  Testing & Line 2                        \\
  Testing & Line 3 \verb|X| \\
  Testing & Line 4                        \\
\end{tabular}

gives, by default,

\begin{tabular}{ll}
	Testing & Line 1          \\
	Testing & Line 2          \\
	Testing & Line 3 \verb|X| \\
	Testing & Line 4          \\
\end{tabular}
latexindent.pl - V3.10

Published by cmhughes over 3 years ago

enhancements

bug fix

demonstration 1: fineTuning trailing comments

starting with

some before text
 \href{Handbook%20for%30Spoken%40document.pdf}{my document}
some after text 

and using

modifyLineBreaks:
    textWrapOptions:
        columns: 80
        huge: overflow
        all: 1
        perCodeBlockBasis: 1
    removeParagraphLineBreaks:
        all: 1

fineTuning:
    trailingComments:
      notPreceededBy: '(?:(?<!Handbook)(?<!for)(?<!Spoken))'

then the output is (using -m switch):

some before text \href{Handbook%20for%30Spoken%40document.pdf}{my document} some after text

demonstration 2: noIndentBlock with begin and end

starting with

some before text
        this code
                won't
     be touched
                    by
             latexindent.pl!
some after text 

and using

noIndentBlock:
    demo:
        begin: 'some\hbefore'
        body: '.*?'
        end: 'some\hafter\htext'
        lookForThis: 1

gives the output

some before text
        this code
                won't
     be touched
                    by
             latexindent.pl!
some after text

Note that lookForThis is optional in the noIndentBlock field; default is 1.

demonstration 3: spacesBeforeAmpersand

Starting with

\begin{equation}
    \begin{aligned}
    & a = b, \\
    & c = d.
    \end{aligned}
\end{equation}

\begin{equation}
    \begin{aligned}
    a & = b, \\
    c & = d.
    \end{aligned}
\end{equation}

and using

defaultIndent: ' '

noAdditionalIndent:
  aligned: 1

lookForAlignDelims:
   aligned: 
      spacesBeforeAmpersand: 
        default: 2
        leadingBlankColumn: 0

then the result is

\begin{equation}
 \begin{aligned}
 & a = b, \\
 & c = d.
 \end{aligned}
\end{equation}

\begin{equation}
 \begin{aligned}
 a  & = b, \\
 c  & = d.
 \end{aligned}
\end{equation}

The fields default and leadingBlankColumn both take integer values that represent the spaces to be added before ampersands. They are both optional.

latexindent.pl - V3.9.3

Published by cmhughes over 3 years ago

A minor release that updates log file creation https://github.com/cmhughes/latexindent.pl/issues/145; in particular, users can specify, for example,

latexindent.pl -g /dev/null myfile.tex

so that the log file will not be created. Prior to this release, latexindent.pl would fail if the log file could not be created.

The other minor tweak to the logging procedure is that the FATAL method has been created, for situations in which latexindent is called to act on files that do not exist.

latexindent.pl - V3.9.2

Published by cmhughes over 3 years ago

A minor release to include the bugfix for the noindent block bug reported at #266

latexindent.pl - V3.9.1

Published by cmhughes over 3 years ago

Minor updates to documentation, details at https://github.com/cmhughes/latexindent.pl/issues/255 and https://github.com/cmhughes/latexindent.pl/issues/259

Minor updates to fineTuning:

  • keyEqualsValuesBracesBrackets, https://github.com/cmhughes/latexindent.pl/issues/257 which means that, by default, keyEqualsValuesBracesBrackets no longer begin with braces.
  • namedGroupingBracesBrackets, https://github.com/cmhughes/latexindent.pl/issues/258 now starts with a lower-case 'n' in fineTuning so as to be consistent with its appearance elsewhere in defaultSettings.yaml. As this was my mistake, LatexIndent/NamedGroupingBracesBrackets.pm will read from NamedGroupingBracesBrackets (note the upper-case 'N') and a warning is given to the logfile. I plan to support both fineTuning:namedGroupingBracesBrackets and fineTuning:NamedGroupingBracesBrackets for V3.*, but if V4.0 is created, then only namedGroupingBracesBrackets will be supported. I recommend users migrate to namedGroupingBracesBrackets
latexindent.pl - V3.9

Published by cmhughes over 3 years ago

V3.9, March 14, 2021

Small enhancements:

  • https://github.com/cmhughes/latexindent.pl/issues/242, update to -l switch so that instead of only looking for localSettings.yaml, it will also look for (in order): latexindent.yaml, .localSettings.yaml and .latexindent.yaml. Note that you don't need to have all 4, and that for most uses, just 1 of these files should be enough. As previously, using -l=myfile.yaml will only load myfile.yaml and now using -l=myfile.yaml+ will assume that you want to load as many of the following that exist: myfile.yaml, localSettings.yaml, latexindent.yaml, .localSettings.yaml, .latexindent.yaml
  • https://github.com/cmhughes/latexindent.pl/issues/239, update to commandCodeBlocks

bug fixes:

latexindent.pl - V3.8.3

Published by cmhughes almost 4 years ago

This is a minor release that implements fixes for the following issues:

The documentation has been updated with appropriate examples, including details of how to produce alignment such as the following:

\begin{tikzpicture}
	\path (A) edge              node {0,1,L}(B)
	          edge              node {1,1,R} (C)
	      (B) edge [loop above] node {1,1,L}(B)
	          edge              node {0,1,L}(C)
	      (C) edge              node {0,1,L}(D)
	          edge [bend left]  node {1,0,R}(E)
	      (D) edge [loop below] node {1,1,R}(D)
	          edge              node {0,1,R}(A)
	      (E) edge [bend left]  node {1,0,R} (A);
\end{tikzpicture}

and a patch to the textWrap routine, so that spaces are preserved (or not) according to the new field tabstop

x       y

Settings

modifyLineBreaks:
    textWrapOptions:
        columns: 80
        tabstop: 9

Pull request, for reference: https://github.com/cmhughes/latexindent.pl/pull/227

latexindent.pl - V3.8.2

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago

latexindent.pl -

Published by cmhughes over 4 years ago