TransWikia.com

Keep your code readable with smart indenting : Latex

TeX - LaTeX Asked on March 14, 2021

Is there a way to automatically indent a math environment ? By that, I mean a clean set of equations for the writer and this has absolutely no influence on the output pdf. It is just to make readable the text file. In Matlab, ctr+i is doing this smart indenting. I am wondering if there is an equivalent to that in Latex.

Update:
By smart indenting, I mean if for instance you have

begin{equation}
centering
begin{aligned}
    begin{dcases}
       textsf{}  
       textsf{} 
    end{dcases}
    &{hspace{}  textsf{}}
        end{aligned}
    {hspace{}  text{} hspace{}}
    begin{aligned}
        begin{dcases}
       textsf{}  
        textsf{} 
    end{dcases}
&{hspace{}  textsf{}
        end{aligned}

end{equation} 

the set of lines are correctly tabbed with respect to each other. I don’t want to indent them all. I want the indent be such that as the code is clean and you can see the nested part of it.

One Answer

the perl script latexindent allows to indent the LaTeX code, but it must be started by a command. It can be ordered automatically if your editor allows you to create one. Here is what it returns on your code:

begin{equation}
        centering
        begin{aligned}
                begin{dcases}
                        textsf{} 
                        textsf{} 
                end{dcases} 
                 & {hspace{}  textsf{}}
        end{aligned}
        {hspace{}  text{} hspace{}}
        begin{aligned}
                begin{dcases}
                        textsf{} 
                        textsf{} 
                end{dcases} 
                 & {hspace{}  textsf{}
        end{aligned}

end{equation}

Answered by gigiair on March 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP