I’ve used `LaTeXTidy` regularly for some months now, and for me it is all good…with just one niggle:

A common idiom is
\begin{environment} \label{env:whatever}
...
\end{environment}

except in captioned environments (table etc) when you usually want
\begin{environment}
...
\label{env:whatever} \end{environment}

This idiom is reflected perfectly in the LaTeX bundle’s ctrl-< functionality, which I love so much I should probably get therapy.

`LaTeXTidy` has the unfortunate feature of moving the \label to its own line, so the result in any case is
\begin{environment}
...
\label{env:whatever}
...
\end{environment}

My issue is that this cripples code folding. Before I run `LaTeXTidy` I can fold my LaTeX so I only see the environments and their \labels, which is exactly what I want. After `LaTeXTidy`, code folding hides the \labels, so all I see is \begin{environment}\end{environment}, which is probably not what anyone wants. I have Find&Replace workarounds, to put the \labels back on the lines I want them on, but it would be really neat if `LaTeXTidy` effectively left them there.

The LaTeX bundle is a terrific piece of work in general, and although I use it every day this is the only minor grumble I can think of. And there is nothing else I would seriously suggest changing about `LaTeXTidy`.

Robert

On 11 Feb 2015, at 23:49, René Schwaiger <sanssecours@f-m.fm> wrote:

Hi Anthony,

On 11 Feb 2015, at 23:51 , Anthony V. Pulido <anthony.pulido@gmail.com> wrote:

I've followed the instructions in the error message and installed File::HomeDir. Latexindent now works, but despite the image of comprehensiveness the documentation seems to provide, it seems to lack some features of the previous version of latex tidy. Is there anyway to get the previous version back?

yes. I will try to incorporate both commands and use `LaTeXTidy` as default tomorrow in the morning (GMT+1). It is quite late here and I fear that if I change something now, that I would only make things worse. 

Although latexindent nicely formats align environments and matrices, some of the automation available in the previous version of 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. The 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. 

Thank you for the thorough analysis of the tool. I think the authors of `latexindent` might be interested about your thoughts too. You can report bugs, or request features at the official [GitHub page](https://github.com/cmhughes/latexindent.pl/issues). Your comments could provide the feedback that they need to improve `latexindent` not only for you, but also other users who use `latexindent` now or plan to use it sometimes in the future.

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.

I have to admit that I did not use “Tidy” for my own documents. For me tex documents pretty much just looked the same way after I invoked “Tidy”. This was also the reason why I replaced `LaTeXTidy` with `latexindent`. `latexindent` just produced nicer looking output when I invoked it on a sample document.

Would it be possible for the old latex tidy to be re-added to the bundle alongside latexindent?

That is my current plan.

Or would it be possible to configure latexindent to mimic certain features of latextidy?

I guess it could be possible to mimic some of the features. I did not study the documentation of `latexindent` tough. As I already mentioned, feedback/feature requests on the official GitHub page might help to improve `latexindent`.

Anthony

Kind regards,
 René

_______________________________________________
textmate mailing list
textmate@lists.macromates.com
http://lists.macromates.com/listinfo/textmate