Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. $line=<>;
  4. $count=0;
  5. while ($line=~s/\t/ & /) { $count++; }
  6. $greeting="\\begin{tabular}{";
  7. for (0..$count) { $greeting.="c"; }
  8. $greeting.="}\n";
  9. print $greeting;
  10. $line=~s/\n/\\\\\n/g;
  11. $hline="\\hline\n";
  12. print $hline.$line.$hline;
  13. while ($line=<>) {
  14. $line=~s/\t/\ &\ /g; #Convert plaintext tabs to TeX-style alignment tabs
  15. $line=~s/\n/\\\\\n/g; #Add trailing backslashes to end the row
  16. $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:
  17. $line=~s/\^\{(-*)([^1-9]*)([1-9]*)\}/\^\{$1$3\}/g; #Second step: strip plus signs and leading zeroes from the exponents
  18. print "$line";
  19. }
  20. print "\\\\\n".$hline."\\end{tabular}\n";
Add Comment
Please, Sign In to add comment