Discussion:
TeX/LaTeX code beautifier
Add Reply
c***@gmail.com
2015-10-20 21:28:30 UTC
Reply
Permalink
Raw Message
On Monday, July 30, 1990 at 4:55:48 PM UTC-7, ***@violet.berkeley.edu wrote:
> Is there a tool to assist in coding TeX and LaTeX documents and
> macros? I have in mind something like "indent" for C. Among other
> things, it indents program blocks, breaks lines and checks some of the
> syntax.
>
> Geraldo Veiga

Excuse the bump but this post is high so it seems that people actually visit this often.
I have created one https://c.albert-thompson.com/latex-pretty/ It focuses on indenting blocks. It does not check syntax though.
Peter Flynn
2015-10-20 22:41:19 UTC
Reply
Permalink
Raw Message
On 20/10/15 22:28, ***@gmail.com wrote:
> On Monday, July 30, 1990 at 4:55:48 PM UTC-7, ***@violet.berkeley.edu wrote:
>> Is there a tool to assist in coding TeX and LaTeX documents and
>> macros? I have in mind something like "indent" for C. Among other
>> things, it indents program blocks, breaks lines and checks some of the
>> syntax.
>>
>> Geraldo Veiga
>
> Excuse the bump but this post is high so it seems that people actually visit this often.
> I have created one https://c.albert-thompson.com/latex-pretty/ It focuses on indenting blocks. It does not check syntax though.

The answer is much the same as it was in 1990: most [La]TeX-sensitive
editors do something like this already. Emacs is possibly the locus
classicus.

In any case, indentation routines should use a small default indent (2
spaces, maybe 3) because many people write complex code which means many
indent levels. Having the default indent set to 7 or 8 is way too much.
The amount should of course be configurable anyway. Using TAB characters
to indent is strictly a no-no.

///Peter
Anonymous
2015-10-25 16:49:29 UTC
Reply
Permalink
Raw Message
> > I have created one https://c.albert-thompson.com/latex-pretty/ It
> > focuses on indenting blocks. It does not check syntax though.
>
> The answer is much the same as it was in 1990: most
> [La]TeX-sensitive editors do something like this already. Emacs is
> possibly the locus classicus.

Actually a pretty-printer would be quite useful for formatting
machine-generated LaTeX code. When a script auto-generates LaTeX
code, it's cumbersome to do good indenting, and well-formatted LaTeX
within the script often uglifies the shell code that produces it.

So a pretty-printer is a good idea. But bizarre that it's a web tool.
This means using it for machine-produced code entails web-scraping.
It also means the content is shared with the webmaster. Ideally
someone would expand on an existing pretty-printer tool like /tidy/
(an HTML pretty-printer).
c***@gmail.com
2017-05-26 19:58:12 UTC
Reply
Permalink
Raw Message
Perhaps latexindent.pl would be useful:

https://github.com/cmhughes/latexindent.pl

As a disclaimer, I'm the author.
Chris
S Gilles
2017-05-27 08:56:47 UTC
Reply
Permalink
Raw Message
Perhaps LLF might be another option:

http://repo.or.cz/llf.git

Disclaimer: I'm the author of this one, because I wanted to be able
to fully reflow/beautify my LaTeX to 72 columns where possible (like
AUCTeX) but was in the process of abandoning Emacs.
Loading...