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
Bot releases are hidden (Show)
Published by cmhughes about 3 years ago
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 \\
}
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}
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}
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}
Published by cmhughes over 3 years ago
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
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.
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.
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.
Published by cmhughes over 3 years ago
A minor release to include the bugfix for the noindent
block bug reported at #266
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
Published by cmhughes over 3 years ago
Latexindent/Logger.pm
for implementation.Small enhancements:
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
bug fixes:
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
Published by cmhughes over 4 years ago
Bug fix addressing the issue at https://github.com/cmhughes/latexindent.pl/issues/207