my Latex and Tex4ht cheat sheet
my Latex cheat sheet - 12000.org
my Latex cheat sheet - 12000.org
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
\documentclass[]{article}<br />
\usepackage{luacode}<br />
\begin{luacode*} -- CVS API thanks to http://nocurve.com/simple-csv-read-<strong>and</strong>-write-using-lua/<br />
local function split(str, sep)<br />
fields={}<br />
local matchfunc = string.gmatch(str, "([^"..sep.."]+)")<br />
if not matchfunc then return {str} end<br />
for str in matchfunc do<br />
table.insert(fields, str)<br />
end<br />
return fields<br />
end<br />
function read(path, sep, tonum)<br />
tonum = tonum or true<br />
sep = sep or ','<br />
local csvFile = {}<br />
local file = assert(io.open(path, "r"))<br />
for line in file:lines() do<br />
fields = split(line, sep)<br />
if tonum then -- convert numeric fields to numbers<br />
for i=1,#fields do<br />
fields[i] = tonumber(fields[i]) or fields[i]<br />
end<br />
end<br />
table.insert(csvFile, fields)<br />
end<br />
file:close()<br />
return csvFile<br />
end<br />
function getCVS(fileName)<br />
local m = read(fileName) -- read file csv1.txt to matrix m<br />
local nRow = #m<br />
local nCol = #m[1]<br />
tex.sprint("\\begin{tabular}{")<br />
for j=1,#m[1] do<br />
tex.sprint("|l")<br />
end<br />
tex.print("|}\\hline")<br />
for i = 1,nRow do<br />
for j = 1,nCol do<br />
tex.sprint(m[i][j])<br />
if j