Giter Site home page Giter Site logo

cmhughes / latexindent.pl Goto Github PK

View Code? Open in Web Editor NEW
827.0 9.0 83.0 50.02 MB

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.

License: GNU General Public License v3.0

Perl 11.40% Shell 4.01% TeX 84.45% CMake 0.03% Batchfile 0.07% Dockerfile 0.04%
latex beautify beautifier perl yaml formatter

latexindent.pl's People

Contributors

arkandias avatar chenrui333 avatar cmhughes avatar dependabot[bot] avatar eggplants avatar fengzyf avatar holzhaus avatar hsloot avatar jasjuang avatar jeanlego avatar jessestricker avatar jun-sheaf avatar kianmeng avatar krappramiro avatar mahdikooshkbaghi avatar mikachu2333 avatar msramalho avatar musm avatar nechtarg avatar newptcai avatar nzqo avatar qiancy98 avatar saltsmart avatar saxyx avatar tdegeus avatar teatimeguest avatar valtterikantanen avatar xu-cheng avatar xuehaipan avatar yzhang-gh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

latexindent.pl's Issues

Perl regex warnings

I get a bunch (like 50+) of Perl related regex warnings of unescaped braces when executing latexindent from command line.

System: macOS 10.12, TexLive2016, latexindent version 2.1R

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*%\*\s*\\begin{ <-- HERE (.*?)}/ at /Library/TeX/texbin/latexindent line 1047.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*%\*\s*\\end{ <-- HERE (.*?)}/ at /Library/TeX/texbin/latexindent line 1073.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^%\s*\\end{ <-- HERE (.*?)}/ at /Library/TeX/texbin/latexindent line 1199.

Seems to be related to this Perl core update: http://unix.stackexchange.com/questions/238539/automake-error-unescaped-left-brace-in-regex-is-deprecated

Header of latexindent.pl not flexible

Hi Chris,

I am again ;-)

For me the first line of latexindent.pl produces an error because I am working with perlbrew. After changing the first line to #!/usr/bin/env perl it works as expected.

I am not familiar with perl, so I can't evaluate this changes.

Regards
Marco

Option to start \begin and \end environment on new lines

I think this needs an option to put \begin{<name>} and \end{<name>} on thier own line.

For example, it would be nice to translate

\begin{minipage}{.5\textwidth}
body\end{minipage}

into

\begin{minipage}{.5\textwidth}
    body
\end{minipage}

Missing space in columns with umlauts in UTF-8

I noticed that when formatting a tabular in a UTF-8-document with latexindent the "&" are not aligned correctly if some columns contain text with umlauts (ä, ö, ü, ß) and some don't. In columns with umlauts there's always one space missing per umlaut as if latexident interprets umlauts as two letters.

If I switch the document encoding to ISO-8859-1 and run latexident, everything is aligned perfectly.

long versions of options/flags/switches

I'd like to have the option to have 'long' options, e.g latexindent --overwrite myfile

This will be helpful in adding new flags such as -m or --modify-line-structure or -g=mylog.log or --log-file=mylog.log

Not indenting inside of multiline continued brace contents

Same environment as #14 - this is an extract from the file there.

Default options will turn this (a command from xpatch):

\xapptocmd{\tableofcontents}{%
    \end{singlespace}%
    \pagestyle{plain}%
    \clearpage}{}{}

into this

\xapptocmd{\tableofcontents}{%
\end{singlespace}%
\pagestyle{plain}%
\clearpage}{}{}

while it leaves this alone, properly indented:

\xpretocmd{\tableofcontents}{%
    \begin{singlespace}}{}{}

details in indent.log (phase 1)

try running latexindent.pl on success/table1.tex and you'll see some less than idea PHASE 1 details in the log file, indent.log

log file preferences

logFilePreferences:
       traceModeShowsPerlModuleLocations: 1
       showEveryYamlRead: 1
       showAlmagamatedSettings: 0
       traceModeIncreaseIndent: '>>>>>>'
       traceModeDecreaseIndent: '<<<<<<'
       traceModeBetweenLines: '\n'
       endLogFileWith: 

The ifnextchar[ issue

This has been a known issue since the release of V3.0:

\parbox{
\@ifnextchar[{\@assignmentwithcutoff}{\@assignmentnocutoff}
}

I think that we need a way to specify 'special' names for commands, something like

commandNamesSpecial:
     @ifnextchar\[: 1

which could be added to the command name reg exp.

2 BackUps

Hi, I think the BackUp-switch is missing a thing.
Till now, I can toggle between endless BackUps and 1 BackUp. I dont think that very practically.
Nobody wants to get thousands of BackUps. If you really need it, you do some version control. But 1 backUp isn't enough. In first run of your script, the Backup is written and the indentation done. In the second run, when maybe some new error appears, the BackUp gets overwritten by the indented version.
Thats why I think, 2 BackUps would be a good default. At least, it should be possible to set the number of BackUps in the defaultsettings.

Thank your very much.

EndFinishesWithLineBreak breaks before comment

This example is broken if the switch EndFinishesWithLineBreak is set.

\documentclass{beamer}

\begin{document}

\begin{frame}
	\begin{minipage}{0.5\textwidth}
		blah
	\end{minipage}% 
	\begin{minipage}{0.5\textwidth}
		blah
	\end{minipage}
\end{frame}

\end{document}

Results in: presentation.pdf

After latexindent:

\documentclass{beamer}

\begin{document}

\begin{frame}
	\begin{minipage}{0.5\textwidth}
		blah
	\end{minipage}
	% 
	\begin{minipage}{0.5\textwidth}
		blah
	\end{minipage}
\end{frame}

\end{document}

Results in: presentation.pdf

Is that intended? I think latexindent should do the linebreak after the comment, not before.

Erroneous indentation

I attached a small file where latexindent 3.0 is unable to provide a useful indentation. The file is already formatted by latexindent but the \newifs or \newcommands seem to be causing issues.

Maximum value of indentation

Indentation can get out of hand when nesting goes deep; perhaps a YAML field for the maximum value of indentation, which could be checked at phase 5?

Some errors, `-w` hangs

I get these errors/warnings? when trying to run on https://gist.github.com/rpavlik/ad3f19bcd1aa150c7d6d

Just using latest Git version directly cloned, no customization, no build process performed (is there one?), installed required packages via apt-get on Debian Testing (actually LMDE but close enough)

These get sent to stderr and do not keep it from outputting the formatted document afterwards.

However, if I add -w to the command line, nothing is printed and the app hangs, must be killed with ctrl-c

Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 859, <MAINFILE> line 76.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 865, <MAINFILE> line 86.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 896, <MAINFILE> line 86.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 859, <MAINFILE> line 89.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 865, <MAINFILE> line 102.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 896, <MAINFILE> line 102.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 859, <MAINFILE> line 104.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 193.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 193.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 193.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 193.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 193.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 193.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 198.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 198.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 198.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 198.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 198.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 198.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 865, <MAINFILE> line 212.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 896, <MAINFILE> line 212.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 859, <MAINFILE> line 217.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 859, <MAINFILE> line 224.
Use of uninitialized value $indentNames[-1] in hash element at ../third-party/latexindent.pl/latexindent.pl line 859, <MAINFILE> line 229.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 236.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 236.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 236.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 236.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 236.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 236.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 238.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 238.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 238.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 238.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 238.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 238.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 249.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 249.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 249.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 249.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 249.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 249.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 251.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 251.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 251.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 251.
Use of uninitialized value $command in hash element at ../third-party/latexindent.pl/latexindent.pl line 2030, <MAINFILE> line 251.
Use of uninitialized value $countzeros in numeric eq (==) at ../third-party/latexindent.pl/latexindent.pl line 1343, <MAINFILE> line 251.
Unrecognized escape \i passed through in regex; marked by <-- HERE in m/\\end{\i <-- HERE su@space}/ at ../third-party/latexindent.pl/latexindent.pl line 1525, <MAINFILE> line 317.
Unrecognized escape \i passed through in regex; marked by <-- HERE in m/\\end{\i <-- HERE su@space}/ at ../third-party/latexindent.pl/latexindent.pl line 1525, <MAINFILE> line 335.

How to disable align of `\\` in align environment?

I have some code as

\begin{align*}
a&=b+c\\
c&=d\\
\end{align*}

it will be indent to:

\begin{align*}
    a & =b+c \\
    c & =d   \\
\end{align*}

how to delte the space before \\, since when my formula is long, this will take a lot of space, and make my formula looks ugly. So is there a switch such that it looks like

\begin{align*}
    a & =b+c\\
    c & =d\\
\end{align*}

Indent conditionals

The clauses in an \ifsomething\else\fi aren't indented (and get their insides un-indented), which limits utility for class/package writers (I end up saving the formatted code to a separate file and just merging in the changes I want with a mergetool like meld)

I think it's probably reasonable to do this only if the conditional is the last thing (except for comments) on a line: leaves alone inline conditionals.

Example:

\newif\if@isu@draftcls@
\if@isu@draftcls@
    \RequirePackage[firstpage]{draftwatermark}
    \RequirePackage{datetime}
    \newcommand{\isu@draftfooter}{DRAFT --- rendered \today\ at \currenttime}
\else
    \newcommand{\isu@draftfooter}{}
\fi

Slight corner case, since here we only have a body for \else:

\newif\if@isu@tocnumbersections@
\if@isu@tocnumbersections@\else
    \renewcommand{\cftsecpresnum}{\begin{lrbox}{\@tempboxa}}
    \renewcommand{\cftsecaftersnum}{\end{lrbox}}
\fi

Square brackets in maths mode

This might be related to #35. When I run latexindent with the option alwaysLookforSplitBrackets: 1 I get that

\[
    x \in (0,1] \cup [2,3]
    \]
    This indents incorrectly

This indents as normal when alwaysLookforSplitBrackets: 0 . Is this behaviour intensional? It seems weird to keep track of the square brackets inside of math environments.

\end{document} indented in the level of last (sub)section

I think i have an issue;
if i enable section indentation the \end{document}, which in my settings never should be intended is indented in the level of the last [sub]section{} command.

i think this is a minor fast resolveable issue, if im wrong or messed up my settings im sorry, im new to github and coding, and cloned this repo just because i wasnt able to implement the decreaseIndentation for sections in regex for sublimetext.

Unescaped left brace in regex

perl 5.21.6 complains about unescaped left braces in regex:

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*\\begin{ <-- HERE document}/ at ./latexindent.pl line 623.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*%\*\s*\\begin{ <-- HERE (.*?)}/ at ./latexindent.pl line 993.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*%\*\s*\\end{ <-- HERE (.*?)}/ at ./latexindent.pl line 1019.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^%\s*\\end{ <-- HERE (.*?)}/ at ./latexindent.pl line 1145.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^%\s*\\begin{ <-- HERE (.*?)}/ at ./latexindent.pl line 1166.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*(\$)?\\begin{ <-- HERE \\?(.*?)}/ at ./latexindent.pl line 1567.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^\s*\\end{ <-- HERE \\?(.*?)}/ at ./latexindent.pl line 1628.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\\end{ <-- HERE document}/ at ./latexindent.pl line 1567, <MAINFILE> line 32.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\\end{ <-- HERE example}/ at ./latexindent.pl line 1567, <MAINFILE> line 36.

long lines automatically broken

From JDO:

Hi Chris,

Nice package! I write lots of LaTeX as a professor, and I collaborate
with my students, and we use github for source control. I'm an Emacs
man so I have historically just formatted everything within 80
characters. It looks like you're doing exactly what I've always done
(but I don't see an "80" parameter anywhere?) so that's terrific.

However, my students all appear to prefer paragraphs as a single line.
I never liked that in Emacs until I discovered visual-line-mode, which
is very nice. Would you consider a latexindent option for long lines,
meaning text paragraphs would format as a single line (basically, you
just never insert newlines within a paragraph, everything else is
identical)?

long.txt
long_out.txt
short.txt
short_out.txt

License format

Very minor improvement: If the license is in a certain format, it will be recognized & displayed by github.
https://github.com/blog/2252-license-now-displayed-on-repository-overview
https://help.github.com/articles/adding-a-license-to-a-repository/

The easiest way to have the right format is to delete the license file and then re-add it from the github web interface by clicking the "Create new file" button and then specifying as filename "License.txt". A dropdown menu will appear and ask what license template to use.

github also just introduced the community checklist:
https://github.com/cmhughes/latexindent.pl/community
https://github.com/blog/2380-new-community-tools

Check if/else/fi

At line 920 one should also check "@" sign.
So it may looks like this
if( $_ =~ m/^\s_(if._?)(\s||#|@)/ and $constructIfElseFi{$1})

Example latex:
\if@twoside
\else
\setcounter{page}@ne
\fi

Enhancements to the alignment-at-ampersand routine

I'd like to see something like:

spacesBeforeAmpersand: 1
spacesAfterAmpersand: 1

so that the users can specify any number (>=0) for each.

Possibly also look into justification of columns, e.g

justification: left/right

or maybe even center?

Square brackets not counted correctly

The following code does not get indented as indended:

% arara: indent: {overwrite: yes, trace: on}
\node [scale=8,
    text=black,
    inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 

        here is some text
        here is some text
        here is some text
        here is some text

Presumably it's because the square bracket count is <0.

Overwriting file when there has been no change.

Hello,

% arara: indent: { overwrite : yes } will allways save/overwrite the file, even if there has been no change at all. In TeXnicCenter, after each run the editor will tell me, that the file has been changed outside the editor. This is annoying if just small changes are made or several runs with no changes at all.
I will report this issue to TeXnicCenter as well, as they could do a real diff before throwing this message. But maybe it would be able to latexindent to differ between changed and non changed files. In second case, a new output.tex, overwritten input.tex or BackUp-file is needed.

Thanks a lot for such a great tool.

noIndent block starting %\end{noindent} with spaces

% arara: indent: {overwrite: yes, trace: yes}

% \begin{noindent}
\begin{equation}
    f(x),\quad x\in[0,1)
    \end{equation}
    % \end{noindent}
        text

doesn't work as expected, presumably because %\end{noindent} starts with space.

Using

% arara: indent: {overwrite: yes, trace: yes}

% \begin{noindent}
\begin{equation}
    f(x),\quad x\in[0,1)
    \end{equation}
% \end{noindent}
        text

works as expected.

Check the line that matches %\end{noindent} and make sure that it can accept multiple spaces (possibly none) at the beginning.

Option for NOT to align the tailing "\\"

Hi Chris, your tool is GREAT! It is the cure for the people like me with minor obsessions. But is possible to add an option in the settings that make it NOT to align the tailing "\"? E.g. if I had this long equation

A = BBBB + CCCC &+ DDD \
&+ EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE \
&+ FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

latexindent always seemed to insert a lot of white space between DDD and "\" which actually didn't help if this line was super-long and the text editor was set to the "wrap" mode.

Or is it already there that I just haven't found it?

Allow localsettings to be named differently

latexindent -l=mysettings.yaml myfile.tex

Would allow mysettings.yaml to be used. If the -l flag doesn't use a file, then it will be assumed to be named localsettings.yaml, as per the current behaviour.

Maximum character per line

Is it possible to autoformat so the max number of character number will be lets say 80 per line? It will be super awesome if you can add in this feature.

better formatting for tables

I would like latexindent to format tables taking into account \multicolumns and lines where some & alignment chars are missing.

For example, I would like the code

\begin{table}[h]
  \caption{Muuntajan nimellisarvot ja ylajannitepuolelta mitatut arvot}
  \centering
  \begin{tabular}{r@{\hspace{2pt}}c@{\hspace{2pt}}lr@{\hspace{2pt}}c@{\hspace{2pt}}lr@{\hspace{2pt}}c@{\hspace{2pt}}l}
    \toprule
    \multicolumn{3}{l}{Nimellisarvot} & \multicolumn{3}{l}{Tyhjakayntikoe} & \multicolumn{3}{l}{Oikosulkukoe} \\
    \midrule
    $S_N$    & $=$ & $\SI{1000}{\kV\A}$ & $U_0$ & $=$ & $U_{N1}$             & $U_k$ & $=$ & $\SI{360}{\V}$  \\
    $U_{N1}$ & $=$ & $\SI{6000}{V}$     & $I_0$ & $=$ & $\SI{1.67}{\ampere}$ & $I_k$ & $=$ & $I_{N1}$        \\
    $U_{N2}$ & $=$ & $\SI{400}{\volt}$  & $P_0$ & $=$ & $\SI{1550}{\watt}$   & $P_k$ & $=$ & $\SI{8200}{\W}$ \\
    $f_N$ & $=$ & $\SI{50}{\hertz}$ & & \\
    \bottomrule
  \end{tabular}
\end{table}

to be formatted by latexindent as

\begin{table}[h]
  \caption{Muuntajan nimellisarvot ja ylajannitepuolelta mitatut arvot}
  \centering
  \begin{tabular}{r@{\hspace{2pt}}c@{\hspace{2pt}}lr@{\hspace{2pt}}c@{\hspace{2pt}}lr@{\hspace{2pt}}c@{\hspace{2pt}}l}
    \toprule
    \multicolumn{3}{l}{Nimellisarvot}   & \multicolumn{3}{l}{Tyhjakayntikoe} & \multicolumn{3}{l}{Oikosulkukoe} \\
    \midrule
    $S_N$    & $=$ & $\SI{1000}{\kV\A}$ & $U_0$ & $=$ & $U_{N1}$             & $U_k$ & $=$ & $\SI{360}{\V}$     \\
    $U_{N1}$ & $=$ & $\SI{6000}{V}$     & $I_0$ & $=$ & $\SI{1.67}{\ampere}$ & $I_k$ & $=$ & $I_{N1}$           \\
    $U_{N2}$ & $=$ & $\SI{400}{\volt}$  & $P_0$ & $=$ & $\SI{1550}{\watt}$   & $P_k$ & $=$ & $\SI{8200}{\W}$    \\
    $f_N$    & $=$ & $\SI{50}{\hertz}$  &                                    &                                  \\
    \bottomrule
  \end{tabular}
\end{table}

Can it somehow be done?

Thanks you Chris for your work on latexindent.

Karl

nested environments, etc.

Hello,

Back in February, I wrote the TextMate list when latexindent was added to it. I use LaTeX Tidy often, TextMate's default LaTeX formatter, and found that latexindent was formatting documents much differently, and in a way that I think might not have been intended. I'm not sure if these issues have been dealt with or brought up already, but I thought I would bring them up here. (I think issue #22 might be related, but I think the text below might consider a little more.)

Thanks!

This is what I wrote:

Although latexindent nicely formats align environments and matrices, some of the automation available in latex tidy seems to have been lost.

For example, consider the following:

\begin{lem}
    \label{1.19:lem1}
    \[ \left\{ 
    \begin{matrix}
        p \in \al\\
        q \notin \al 
    \end{matrix}
    \right\}\implies p < q.\]
\end{lem}

which was indented by latex tidy. Latexindent now indents this as:

\begin{lem}\label{1.19:lem1} 
    \[ \left\{      
        \begin{matrix}
            p \in \al    \\
            q \notin \al 
        \end{matrix}
        \right\} 
        \implies p < q.\]
        \end{lem}

If I move the last \] to the next line, latexindent indents this as

\begin{lem}\label{1.19:lem1} 
    \[ \left\{      
        \begin{matrix}
            p \in \al    \\
            q \notin \al 
        \end{matrix}
        \right\} 
        \implies p < q.
    \]
\end{lem}

which looks better, but means that I now have to format my files according to latexindent's rules for it to work correctly. Somehow, this seems to defeat the purpose of an automatic text formatter. The pattern in the example is repeated often in documents of mine thousands of lines long and so, when this behavior of latexindent cascades, it causes lines that should not be indented, to be indented. For example, the following was formatted by latexindent:

\begin{lem}\label{xyz} 
    \[ \left\{      
        \begin{matrix}
            p \in \al    \\
            q \notin \al 
        \end{matrix}
        \right\} 
        \implies p < q.\]
        \end{lem}

        This text should be at the beginning of the line.

        \begin{lem}\label{xyz} 
            \[ \left\{      
                \begin{matrix}
                    p \in \al    \\
                    q \notin \al 
                \end{matrix}
                \right\} 
                \implies p < q.\]
                \end{lem}

Latex tidy would have had no problem with this. Documents of mine tend to consist of environments nested several levels deep, (which is why latex tidy is important to me) and now the test copy on which I tried latexindent has text indented off the screen. Other examples of unexpected behavior, which might not be a complete list... :

after \documentclass{...} latexindent does not adjust indentation, and so

\documentclass{article}

\usepackage{...}

     \usepackage{...}

            \usepackage{...}

is left untouched. Latex tidy would have brought them to the beginning of the line.

Latexindent does not seem to put text inside \[ \] on a separate line, whereas latex tidy did, and so,

asdadfa \[ sdfada \] asdfasdfa

would have been changed to

asdadfa
\[ sdfada \]
asdfasdfa

Latexindent leaves it unchanged.

It is the same with environments:

\begin{abc} jkl \end{abc}

would have been changed to

\begin{abc}
   this text would be indented.
\end{abc}

but latexindent leaves it untouched.

It also doesn't compress multiple blank lines. In summary, latex tidy could take almost any mess I typed and put it in the right place.

Exit code enhancement

There are lots of different ways that the script can exit; it would be useful to have different exit codes for each instance with details both in the help, e.g latexindent -e and as an appendix in the manual with advice on how to fix each one.

Brace matching

The current state of https://github.com/cmhughes/latexindent.pl/tree/object-oriented-approach is progressing with commands that have arguments; it does fine with commands that begin with a backslash, but there are many cases where it will (as yet) fail.

For example, it will, at the moment, not pick up {*{11}{RO}R} in the following correctly. Also, anything like tikz/pgf keys with braces (that don't have a backslash) will not be picked up.

\documentclass{article}
\usepackage{array}
\newcolumntype{R}{>{\displaystyle}r} % automatically in display math style
\newcolumntype{O}{>{{}}c<{{}}}       % "O" for "operator" ...
\begin{document}
\[
\setlength\arraycolsep{0pt} % no need for extra intercolumn whitespace
\begin{array}{*{11}{RO}R}
S &=& 1 &-& \frac{1}{2} &+& \frac{1}{3} &-& \frac{1}{4} &+& \frac{1}{5} 
        &-& \frac{1}{6} &+& \frac{1}{7} &-& \frac{1}{8} &+& \frac{1}{9} 
        &-& \frac{1}{10}&+& \cdots \\[2.5ex]
\frac{1}{2}S 
  &=&   & & \frac{1}{2} & &             &-& \frac{1}{4} & &             
        &+& \frac{1}{6} & &             &-& \frac{1}{8} & &             
        &+& \frac{1}{10}
\end{array}
\]
\end{document} ```

For reference, the above came from http://tex.stackexchange.com/questions/339503/how-to-align-operators-using-alignat-or-someother-environment/339521#339521

Also consider `@{}l@{}` which is a common declaration in `tabular`, `array`, etc.

Blank lines before and after environments or sections

The new version is awesome. The only thing I currently miss is these options (maybe I just can not find it):

I prefer to have my code formatted like this:

some text

\[
    something
\]

some other text

as well as

some text

\begin{env1}
    \begin{env2}
        something
    \end{env2}
\end{env1}

some other text

as well as

\section{something}

    some text

    \subsection{some other thing}
    
        some other text

\section{yet another thing}

Note the empty lines before and after an environment or section.

Thanks for your work.

Encoding of .log-file (trace)

Hello,

really not important, but not that beautiful: The logging of latexindent is not written in utf8. When I switch on tracing, I see a lot of "werden über unterschiedliche Zuströmwinkel" and so on. Maybe that's easy to handle so I just report this. For English writing persons it would never have been noticed, I guess.

Thanks a lot.

Bug with brackets

% This simplified example is processed wrongly:

\onecopy{1}{ % without this statement formation is correct

\begin{tabular}{||||}% !! BUG !!

% no intendation
\begin{picture}(0,0){
\put(0,0){\epsfig{file=testfile.eps,scale=1}}
}
\end{picture} & 1 & 2

\end{tabular}% !! BUG !!

}

noindent not working for file

I try to use an noident-environment for table as latexindent has issues with a custom table (using a rotatebox and manual line break inside a cell). After running latexindent on this file some text gets indented, even though the %\begin{noindent} command should avoid this.

\documentclass[]{beamer}

\begin{document}

\begin{frame}
		
	%\begin{noindent}
sasf asf 
	%\end{noindent}
		
\end{frame}

\end{document}

I am running the latest version from the repository.

No output on windows

texlive 2016, I just updated all the packages and have
latexindent.exe ver 43326
on windows 10 creators update

running latexindent.exe -h produces no result (i.e. terminal blank)

a while back this used to work so I'm not sure what changed (bummer since I really like this package)

yaml formatting error in defaultSettings.yaml

Using the default settings appears to fail for me. Probably a result of some misconfiguration of my machine, but some pointers on how to fix it would be appreciated.

tsbertalan@flapjack:~/src$ git clone [email protected]:cmhughes/latexindent.plx.git
Cloning into 'latexindent.plx'...
remote: Counting objects: 511, done.
remote: Compressing objects: 100% (225/225), done.
remote: Total 511 (delta 305), reused 492 (delta 286)
Receiving objects: 100% (511/511), 7.41 MiB | 6.11 MiB/s, done.
Resolving deltas: 100% (305/305), done.
tsbertalan@flapjack:~/src$ cd latexindent.plx/
tsbertalan@flapjack:~/src/latexindent.plx$ perl latexindent.pl success/bigTest.tex 
 ERROR  There seems to be a yaml formatting error in defaultSettings.yaml
        Please check it for mistakes- you can find a working version at https://github.com/cmhughes/latexindent.plx
        if you would like to overwrite your current version

        Exiting, no indendation done.
tsbertalan@flapjack:~/src/latexindent.plx$ 

I tried

sudo cpan YAML

which installed some stuff, but nothing changed WRT latexindent.pl

This is on Ubuntu 13.04.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.