-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/teuben/nemo
- Loading branch information
Showing
2 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
File Name Description | ||
--------------------------------------------------------------------------- | ||
MANIFEST This file | ||
Makefile Root makefile for NEMO (created by configure) | ||
Makefile.in Root makefile for NEMO | ||
README.md Quick info on NEMO and where to continue reading | ||
INSTALL Pointer to other instructions | ||
README.install Installation instructions | ||
VERSION major.minor.patch - see src/scripts/version | ||
nemo_start.sh Startup for bourne shell | ||
nemo_start.csh Startup for C shell | ||
nemo_start.sh.in Startup for bourne shell | ||
nemo_start.csh.in Startup for C shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#! /usr/bin/env python | ||
# | ||
# convert a table to latex. | ||
# table should only have values, though # comment lines are converted to latex % lines | ||
# | ||
# Test example: tabgen - 10 4 | ./tablatex.py | ||
|
||
import sys | ||
|
||
h1 = """ | ||
% this table has been generated by the tablatex.py converter, you will likely need to edit it | ||
\\begin{table}[!h] | ||
\\caption{YOUR CAPTION} | ||
\\smallskip | ||
\\begin{center} | ||
{\\small | ||
""" | ||
|
||
h2t = "\\begin{tabular}{%s} %%l=left c=center r=right" | ||
|
||
h3 = """ | ||
\\tableline | ||
\\noalign{\\smallskip} | ||
""" | ||
|
||
h4t = "%s\\\\" | ||
|
||
h5 = """ | ||
\\noalign{\\smallskip} | ||
\\tableline | ||
\\noalign{\\smallskip} | ||
""" | ||
|
||
# 0.005 & 0.42-0.48 & 50\\ | ||
|
||
h6 = """ | ||
\\noalign{\\smallskip} | ||
\\tableline % Sometimes you just need a line between table rows | ||
\\end{tabular} | ||
} | ||
\\end{center} | ||
\\end{table} | ||
% end of generated table | ||
""" | ||
|
||
|
||
def readtable(file=sys.stdin): | ||
""" gobble the file | ||
""" | ||
if file is not sys.stdin: | ||
fp = open(file,'r') | ||
else: | ||
fp = sys.stdin | ||
lines = fp.readlines() | ||
if file is not sys.stdin: | ||
fp.close() | ||
return lines | ||
|
||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) == 1: | ||
lines = readtable() | ||
else: | ||
lines = [] | ||
for f in sys.argv[1:]: | ||
lines = lines + readtable(f) | ||
|
||
ncols = len(lines[0].split()) | ||
fmt = "" | ||
col = "" | ||
for i in range(ncols): | ||
fmt = fmt + "l" | ||
if i==0: | ||
col = "col1 " | ||
else: | ||
col = col + "& col%d " % (i+1) | ||
|
||
print(h1) | ||
h2 = h2t % fmt | ||
print(h2) | ||
print(h3) | ||
h4 = h4t % col | ||
print(h4) | ||
print(h5) | ||
for line in lines: | ||
if line[0] == '#': | ||
print('% ',line) | ||
continue | ||
words = line.strip().split() | ||
out = "" | ||
for w in words: | ||
if len(out)==0: | ||
out = w | ||
else: | ||
out = out + " & " + w | ||
out = out + "\\\\" | ||
print(out) | ||
print(h6) |