Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- $line=<>;
- $count=0;
- while ($line=~s/\t/ & /) { $count++; }
- $greeting="\\begin{tabular}{";
- for (0..$count) { $greeting.="c"; }
- $greeting.="}\n";
- print $greeting;
- $line=~s/\n/\\\\\n/g;
- $hline="\\hline\n";
- print $hline.$line.$hline;
- while ($line=<>) {
- $line=~s/\t/\ &\ /g; #Convert plaintext tabs to TeX-style alignment tabs
- $line=~s/\n/\\\\\n/g; #Add trailing backslashes to end the row
- $line=~s/([0-9])E([+,-]{0,1}[0-9]{1,2})([^0-9])/$1 \$\\times\$ \$10\^\{$2\}\$$3/g; #Convert "2.3E+08"-style scientific notation to TeX markup:
- $line=~s/\^\{(-*)([^1-9]*)([1-9]*)\}/\^\{$1$3\}/g; #Second step: strip plus signs and leading zeroes from the exponents
- print "$line";
- }
- print "\\\\\n".$hline."\\end{tabular}\n";
Add Comment
Please, Sign In to add comment