diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/odsfile/odsfile.pdf | bin | 185396 -> 185413 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/odsfile/odsfile.tex | 25 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty | 62 |
3 files changed, 75 insertions, 12 deletions
diff --git a/Master/texmf-dist/doc/lualatex/odsfile/odsfile.pdf b/Master/texmf-dist/doc/lualatex/odsfile/odsfile.pdf Binary files differindex c5df9e1ba0f..f5f7d737eee 100644 --- a/Master/texmf-dist/doc/lualatex/odsfile/odsfile.pdf +++ b/Master/texmf-dist/doc/lualatex/odsfile/odsfile.pdf diff --git a/Master/texmf-dist/doc/lualatex/odsfile/odsfile.tex b/Master/texmf-dist/doc/lualatex/odsfile/odsfile.tex index e1fb2b46118..d206381a9f2 100644 --- a/Master/texmf-dist/doc/lualatex/odsfile/odsfile.tex +++ b/Master/texmf-dist/doc/lualatex/odsfile/odsfile.tex @@ -2,7 +2,7 @@ \usepackage{odsfile,tgschola,metalogo,hyperref,xspace,microtype,showexpl,booktabs,url} \author{Michal Hoftich (\url{michal.h21@gmail.com})} \title{The \textsf{odsfile} package:\\ -accessing of the \textsf{opendocument spreadsheet} from \LaTeX{} documents\thanks{Version 0.2, last revisited 2012-08-12.} +accessing of the \textsf{opendocument spreadsheet} from \LaTeX{} documents\thanks{Version 0.3, last revisited 2013-12-27.} } \usepackage[english]{babel} \lstloadlanguages{[LaTeX]Tex} @@ -114,10 +114,11 @@ in this case you can use \item[manually specified list] If column headings are not specified in the file, you can set them manually. \begin{LTXexample} \begin{tabular}{ll} -\includespread[columns=head,columns={title,amount},sheet=List2] +\includespread[columns={title,amount},sheet=List2] \end{tabular} \end{LTXexample} \end{description} +\item[columnbreak] Command inserted in manual linebreaks in cells. Default value is |\linebreak| \item[rowseparator] Rows are normally separated with newlines, if you really want, you can separate them with hlines. @@ -142,6 +143,12 @@ as plaintext or input for plotting functions. \end{LTXexample} For more info about templates, see next section \ref{sec:tpl} +\item[coltypes] When using template, column types are inferred automatically. If that doesn't work well in your case, you can specify them manually with |coltypes| option. + + \begin{LTXexample} + \includespread[columns=head, template=booktabs, coltypes=lrr] + \end{LTXexample} + \item[rowtemplate] \makeatletter \edef\@currentlabel{rowtemplate} @@ -168,8 +175,10 @@ there is default template: Code |-{variable name}| inserts one of the following variables: \begin{description} -\item[coltypes] This is code to be inserted in |\begin{tabular}{coltypes}|. In current version, it inserts |l| for left alignment column, for all columns of inserted table. -It should be possible to use more intelligent method based on types of column content, or \ods styles, maybe in future versions some of them will be used. If you want other alignment of columns now, you have to specify |\begin{tabular}{column types}| manually. +\item[coltypes] This is code to be inserted in |\begin{tabular}{coltypes}|. %In current version, it inserts |l| for left alignment column, for all columns of inserted table. +%It should be possible to use more intelligent method based on types of column content, or \ods styles, maybe in future versions some of them will be used. If you want other alignment of columns now, you have to specify |\begin{tabular}{column types}| manually. +The |p| column specifier is used for each column, where cell with manual line break occurs, |l| is used otherwise. + \item[colheading] Column headings. \item[rowsep] It inserts row separator defined with |rowsepartor| key of |\includespread|. It is used in default style to delimit column headings and table contents. \item[content] Tabular data. @@ -209,7 +218,7 @@ Position specifies cell, where data should be added, if you leave it blank, it w \end{AddRow} \begin{AddRow}[3] \AddString{third row}{} - \AddNumber{22}{3} + \AddNumber{22}{2} \end{AddRow} \includespread[columns=head,template=booktabs] \end{LTXexample} @@ -327,6 +336,12 @@ CC & 5 & 7 \section{Changes} \begin{description} +\item[v0.3] +\begin{itemize} + \item Added support for multiline cells + \item Improved automatic column types generation + \item Added new options, |coltypes| and |columnbreak| +\end{itemize} \item[v0.2] \begin{itemize} \item LuaXML is now distributed as separate library, so other projects can use it. diff --git a/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty b/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty index b4c7f617e18..6ec21d15860 100644 --- a/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty +++ b/Master/texmf-dist/tex/lualatex/odsfile/odsfile.sty @@ -26,7 +26,12 @@ rowseparator=[[\\n]] }{% \luaexec{rowseparator="\luatexluaescapestring{#1}"} } - +\define@key{includespread}{columnbreak}{% + \luaexec{columnbreak="\luatexluaescapestring{\unexpanded{#1}}{}"} +} +\define@key{includespread}{coltypes}{% + \luaexec{coltypes="\luatexluaescapestring{\unexpanded{#1}}"} +} \define@choicekey*+{includespread}{columns}[\val\nr]{head,top,none}{% \ifcase\nr\relax% \luaexec{columns=1}% @@ -84,22 +89,60 @@ rowtemplate=nil columns=nil currenttemplate = nil rowtemplate = nil + columnbreak = "\\linebreak{}" + coltypes = nil }% \setkeys{includespread}{#1}% \luaexec{% body = odsreader.getTable(odsfile,sheetname) local values = odsreader.tableValues(body,range[1],range[2],range[3],range[4]) %-- Conversion of odsfile table values to LaTeX tabular - local rowValues = function(row) + local concatParagraphs = function(column) + if type(column) =="table" then + return table.concat(column, columnbreak), true + end + return column, false + end + local rowValues = function(row, headings) + local headings = headings or {} local t={} - for _,column in pairs(row) do table.insert(t,column.value) end - return t + local i = 1 + for _,column in pairs(row) do + local value, br = concatParagraphs(column.value) + table.insert(t,value) + headings[i] = br + i = i + 1 + end + return t, headings + end + local makeColtypes = function(h) + local maxsize = tex.hsize / 65536 + local h = h or {} + local p = 0 + for _, c in pairs(h) do + if c then p = p + 1 end + end + if p > 0 then + local j = {} + local size = tostring(math.floor(maxsize / \#h)) .. "pt" + for _, c in pairs(h) do + local k = "l" + if c then k = "p{"..size.."}" end + j[\#j+1]= k + end + return table.concat(j) + else + return string.rep("l",\#h) + end end if rowtemplate == nil then + local headings = {} + local currow = {} currenttemplate = currenttemplate or "default" content = {} for i,row in pairs(values) do - table.insert(content,table.concat(rowValues(row)," & ")) + currow, headings = rowValues(row, headings) + table.insert(content,table.concat(currow," & ")) end %-- Column headings handling local colheading="" @@ -111,8 +154,13 @@ rowtemplate=nil columns = rowValues(t[1]) end if type(columns) == "table" then colheading = table.concat(columns," & ") .. "\\\\" end - coltypes = "" - if type(content)== "table" then coltypes= string.rep("l",\#content[1]) end + % coltypes = "" + if type(content)== "table" then + % coltypes= string.rep("l",\#content[1]) + if not coltypes then + coltypes = makeColtypes(headings) + end + end tex.print(odsreader.interp(templates[currenttemplate],{content=table.concat(content, "\\\\ "..rowseparator),coltypes=coltypes,colheading=colheading,rowsep=rowseparator})) else local content = {} |