This is not an exact answer but a reply to one of the comments above. (Can't have formatted code in comment)
the file suggested doesn't work on windows with ActivePerl... i end up
writing my papers on a windows machine.. any ideas what the problem
is?
First, we have to install perl -- either strawberry or active and the perl should be included in system path (important). For some more details pl refer to this question and answer
Then if your .tex file is in a folder c:\myfolder\myfile.tex (say), open command prompt and navigate to this folder typing
cd cd myfolder
If you are on a different drive, other than C: as suggested by Speravir you can also type (instead of above lines)
cd /d c:\myfolder
to reach myfolder.
Ensure that the file indent.plx is also in the same folder (or include its path to the system variable). Now type
perl indent.plx myfile.tex > myfile-formatted.tex
and press Enter.
This will generate a new file called myfile-formatted.tex (which is formatted) in the same folder. A little example:
Before formatting:
\documentclass{article}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{tabular}{rrr}
1 & 1000000 & This \\
2 & 200 & That \\
3 & 300000 & Here \\
4 & 500000 & My name \\
5 & 20000 & Is it so? Then OK \\
6 & 10 & This works. \\
\end{tabular}
% Table generated by Excel2LaTeX from sheet 'Sheet1' and misaligned by me
\begin{tabular}{rrr}
1 & 1000000 & This \\
2 & 200 & That \\
3 &300000 & Here \\
4 & 500000 & My name \\
5 & 20000 & Is it so? Then OK \\
6 & 10 & This works. \\
\end{tabular}
\end{document}
After formatting:
\documentclass{article}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{tabular}{rrr}
1 & 1000000 & This \\
2 & 200 & That \\
3 & 300000 & Here \\
4 & 500000 & My name \\
5 & 20000 & Is it so? Then OK \\
6 & 10 & This works. \\
\end{tabular}
% Table generated by Excel2LaTeX from sheet 'Sheet1' and misaligned by me
\begin{tabular}{rrr}
1 & 1000000 & This \\
2 & 200 & That \\
3 & 300000 & Here \\
4 & 500000 & My name \\
5 & 20000 & Is it so? Then OK \\
6 & 10 & This works. \\
\end{tabular}
\end{document}
Note:
As noted by @speravir:
You must not download directly https://github.com/cmhughes/latexindent.plx !
Go on it, then click on “indent.plx” and then download by clicking on
the “Raw” button! Your error message comes from the HTML file you
actually downloaded.
indent.plxlink: http://tex.blogoverflow.com/2012/08/a-perl-script-for-indenting-tex-files/ – Nov 06 '12 at 01:50doesn't workis not good enough to get help? Please give some more details. It works for me. Please see my long comment as answer. Pl. try that way. I also usedactive perl. Please provide one of your tables so that we can try on that also. – Nov 06 '12 at 22:31