发布时间:2009-12-17 21:46:11
文章类别:表格制作
原文地址:http://blog.sina.com.cn/s/blog_5e16f1770100ggwx.html
QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载
前文有讲到 LaTeX技巧6:Excel2LaTeX表格处理软件图解教程
#!/usr/bin/perl -w
use strict;
open IN, "<", "data.txt"
my @datum = <IN>;
my @titles = split /\s+/, $datum[0];
shift(@titles);
my $title = "
foreach (@titles)
{
}
my $fileColumn = "|" . ("c|" x @titles) . "c|";
print $fileColumn;
open OUT, ">", "table.txt" or die "table.txt";
print OUT "\\begin{tabular}{$fileColumn}\n";
print OUT "
print OUT "$title\n";
print OUT "
foreach (1..@datum-1)
{
}
print OUT "\\end{tabular}";
close IN;
close OUT;
使用时将要生成表格的数据复制到一个文件夹下,命名为data.txt,将此perl脚本另存为**.pl的文件,放在同一文件夹下,双击运行会生成一个table.txt文件,就是Latex格式的tabular,当然得先装个perl解释器。
比如这样的数据需生成LaTex的tabular
张三
李四
周五
吴六
郑七
王八
运行后,生成table.txt如下:
\begin{tabular}{|c|c|c|c|c|c|c|}
张三 & 95 & 56 & 85
& 85 & 76 &
90
李四 & 80 & 90 & 70
& 80 & 97 &
80
周五 & 78 & 65 & 43
& 92 & 64 &
98
吴六 & 76 & 80 & 90
& 73 & 80 &
64
郑七 & 94 & 76 & 85
& 64 & 73 &
80
王八 & 68 & 76 & 80
& 89 & 67 &
77
\end{tabular}
发表评论 取消回复