my Latex and Tex4ht cheat sheet
my Latex cheat sheet - 12000.org
my Latex cheat sheet - 12000.org
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
\documentclass[]{article}<br />
\usepackage{luacode}<br />
\begin{luacode*} -- CVS API: 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 />
local m = read('./c.cvs') -- read file csv file to local matrix m<br />
function getField(row,col) -- API to latex comm<strong>and</strong> below<br />
tex.print(m[row][col])<br />
end<br />
\end{luacode*}<br />
\newcomm<strong>and</strong>\getField[2]{\directlua{getField(#1,#2) }}%<br />
\begin{document}<br />
\begin{table}[]<br />
\centering<br />
\caption{My example}<br />
\begin{tabular}{|l|l|l|l|l|}\hline<br />
1 & \getField{1}{2} & 3 & 4 & 5 \\\hline<br />
6 & 7 & 8 & \getField{2}{5} & 9 \\\hline<br />
10 & 11 & 12 & 13 & 14 \\\hline<br />
\end{tabular}<br />
\end{table}<br />
\end{document}<br />
44