Debian Codegraph @

texmf-dist/doc/lualatex/luaprogtable/luaprogtable-doc.tex

raw
1 \documentclass{l3doc}
2 \usepackage[T1]{fontenc}
3 \usepackage[english]{babel}
4 \usepackage{metalogo}
5 \usepackage{tikz}
6 \usepackage[normalem]{ulem}
7 \usepackage{tcolorbox}
8 \usepackage{booktabs}
9 \usepackage{multirow}
10 \usepackage{colortbl}
11 \usepackage{scrextend}
12 \usepackage{graphicx}
13 \usepackage{luaprogtable}
14
15 \tcbuselibrary{breakable,listings, skins}
16
17 \newcommand{\thispkg}{\pkg{luaprogtable}}
18
19 \title{The \href{https://github.com/xziyue/luaprogtable}{\thispkg}\ package: programmatic table interface for \LuaLaTeX}
20 \author{\href{https://www.alanshawn.com}{Ziyue ``Alan'' Xiang}\\
21 {\scriptsize\ttfamily [email protected]}}
22 \date{\today}
23
24 \NewDocumentEnvironment{optiondetail}{m}{%
25 \par\bigskip\noindent \textbf{Description of #1} \medskip%
26 }{\bigskip}
27
28 \NewDocumentEnvironment{authornote}{}{
29 \paragraph{Author's note}
30 }{\medskip}
31
32 \ExplSyntaxOn
33
34 \dim_new:N \g_enum_indent_dim
35
36 \NewDocumentEnvironment{optionitem}{mm}{
37 \par\noindent\texttt{#1~=~#2}\smallskip
38 \dim_gset:Nn \g_enum_indent_dim {\l__codedoc_trial_width_dim}
39 \begin{addmargin}[2em]{0em}
40 }{\end{addmargin}\medskip}
41
42 \newlist{optionlst}{enumerate}{10}
43 \setlist[optionlst]{label={}, font=\ttfamily, left=\g_enum_indent_dim}
44
45 \newcommand{\optiondf}[1]{\uline{#1}}
46
47 \ExplSyntaxOff
48
49 \newtcblisting{tablesample}{enhanced jigsaw, breakable, colback=white, colframe=black!20}
50
51
52 \begin{document}
53
54 \pagenumbering{Roman}
55
56 \maketitle
57 \tableofcontents
58
59 \clearpage
60
61 \pagenumbering{arabic}
62
63
64 \begin{documentation}
65
66 \section{Introduction}
67
68 The \LaTeX3 project provides \LaTeX\ users with a handful of macros to interpret and manipulate various types of objects (e.g. integers, floating point numbers, token lists, sequences, \ldots) However, there is few existing function that allows users to interact with tables in a programmatic fashion. For example, if a user needs to modify the content of the cell on 20\textsuperscript{th} row and 8\textsuperscript{th} column, he/she needs to navigate the correct cell location among a pile of |&|'s and |\\|'s, which is very inefficient and error-prone. It is very difficult for someone to modify a cell based on the content within it using \LaTeX\ macros.
69
70 \thispkg\ aims to tackle these problems by providing a series of \emph{programmatic} interface for tables. The \cs{LPTGetCellData} and \cs{LPTSetCell} commands allow one to access and alter the content of a single cell. The \env{lptview} environment allows one to modify a small sub-view of a larger table.
71
72 \section{Basic Usage}
73
74 \subsection{Concepts}
75
76 \begin{itemize}
77 \item Coordinate system
78
79 This package uses a 1-indexed row-column-order coordinate system.
80
81 \begin{center}
82 \ExplSyntaxOn
83 \int_new:N \l_tmpc_int
84
85 \begin{tikzpicture}
86 \int_set:Nn \l_tmpa_int {1}
87
88 \int_do_while:nNnn { \l_tmpa_int } < { 5 } {
89 \int_set:Nn \l_tmpb_int {0}
90 \int_set:Nn \l_tmpc_int { \l_tmpa_int }
91 \int_do_while:nNnn {\l_tmpb_int} < {\l_tmpa_int} {
92 \node[minimum~width=1.5cm,
93 minimum~height=0.6cm,
94 outer~sep=0cm, draw=black] at
95 (\fp_eval:n {1.5 * \l_tmpb_int}cm, \fp_eval:n {0.6 * \l_tmpa_int }cm)
96 {\small (\int_eval:n {5 - \l_tmpa_int},~ \int_eval:n {\l_tmpb_int + 1}) };
97 \int_incr:N \l_tmpb_int
98 }
99 \int_incr:N \l_tmpa_int
100 }
101 \end{tikzpicture}
102 \ExplSyntaxOff
103 \end{center}
104
105 \item \hypertarget{index-expr}{Index expressions}
106
107 This package adopts a \emph{Pythonic} indexing convention: each \emph{component} is delimited by `|,|'; within each component, a \emph{range} is separated by a colon (`|:|'). For example, the expression |1,2,3:5| has three components, where the first and second components contain a single index 1, 2, respectively; the third component holds the range $[3, 5]$.
108
109 To comply with \LaTeX\ conventions, both ends of a range are \emph{inclusive}. Therefore, the range |3:5| is made up of three indices, namely 3, 4 and 5. Negative indices indicate reverse access. For example, |-1| refers to the last element; the range |3:-1| contains all indices between 3 and the last element (both ends included).
110
111
112 \item \hypertarget{view-expr}{View expressions}
113
114 In \LaTeX , tables are usually constructed with `|&|' and `|\\|'. However, it is very difficult to write a simple parser for this syntax, because these special symbols can appear in other environments with different meanings. For simplicity, \thispkg\ builds table using \emph{view expressions}. In view expressions, each column is enclosed with braces (|{}|); rows are broken with |\\|. For example, the view expression on the right is equivalent to traditional \LaTeX\ table notation on the left. Note that \textbf{one cannot abbreviate outermost braces in view expressions}.
115
116 \begin{center}
117 \begin{BVerbatim}[gobble=0]
118 a & b & c & d \\
119 e & f & g & h \\
120 i & j & k & l
121 \end{BVerbatim}
122 \hspace{1cm}
123 \begin{BVerbatim}[gobble=0]
124 {a} {b} {c} {d} \\
125 {e} {f} {g} {h} \\
126 {i} {j} {k} {l}
127 \end{BVerbatim}
128 \end{center}
129
130 Sometimes table cells can span across multiple rows/columns. Because \thispkg\ cannot parse \LaTeX\ content, one needs to specify the shape of the cell explicitly for these scenarios. The shape of a cell can be altered by adding |[]| after the closing brace. If a cell spans $n$ columns, one can type |[-n]|; if a cell spans $n$ rows, one can type \verb`[|n]`. For example, view expression (2) is equivalent to traditional \LaTeX\ table (1).
131
132 \begin{enumerate}[label=(\arabic*)]
133 \item
134 \begin{BVerbatim}[baseline=t, gobble=0]
135 \multirow{3}{*}{a} & b & c & d \\
136 & \multicolumn{3}{c}{e} \\
137 & f & g & h
138 \end{BVerbatim}
139
140
141 \item
142 \begin{BVerbatim}[baseline=t, gobble=0]
143 {\multirow{3}{*}{a}}[|3] {b} {c} {d} \\
144 {\multicolumn{3}{c}{e}}[-3] \\
145 {f} {g} {h}
146 \end{BVerbatim}
147
148 \end{enumerate}
149
150
151 \end{itemize}
152
153 \subsection{Creating a new table}
154
155 % \LPTNewTable{table1}{5}{|c|c|c|c|c|}[nrows=5, input method=file]
156 \begin{function}{\LPTNewTable}
157 \begin{syntax}
158 \cs{LPTNewTable} \Arg{table name} \Arg{num cols} \Arg{table preamble} \oarg{table options}
159 \end{syntax}
160
161 Creates a new table named after \meta{table name}. The name of the new table must not be the same as existing ones. The number of columns specified in \meta{num cols} needs to match \meta{table preamble} for the table to work correctly. In general, \meta{table name} should not contain comma and back slash. Starting and trailing white spaces in \meta{table name} will be ignored.
162
163 \begin{optiondetail}{\meta{table options}}
164 \begin{optionitem}{backend}{\optiondf{\{tabular\}}}
165 Specifies the table environment to be used for this table. Apart from |tabular|, one can also use |longtable|, |tabu| and so on. However, the corresponding package must be loaded manually.
166 \end{optionitem}
167 \begin{optionitem}{default before line}{\optiondf{\{\}}}
168 Specifies the default line style before each row.
169 \end{optionitem}
170 \begin{optionitem}{default after line}{\optiondf{\{\}}}
171 Specifies the default line style after each row.
172 \end{optionitem}
173 \begin{optionitem}{default after spacing}{\optiondf{\{\}}}
174 Specifies the default additional spacing after each row. This is achieved by appending |[<dim expr>]| to each row.
175 \end{optionitem}
176 \begin{optionitem}{input method}{file,\optiondf{stringbuffer}}
177 Specifies how \LaTeX\ will read the table source generated by \thispkg.
178 \begin{optionlst}
179 \item[file] The constructed table source will be saved to file system as:
180 \begin{verbatim}
181 \jobname_<table name>.table
182 \end{verbatim}
183
184 It is then read into \LaTeX\ by |\input| macro. This is ideal for debug purposes because the source is visible to the user.
185 \item[stringbuffer] The constructed table source will be fed into \LaTeX\ directly, without the need of file system operations. On \LaTeX\ side, this is still achieved by calling |\input|. However, the corresponding file callback functions on Lua side are changed, which allows \LaTeX\ to read from Lua string buffers directly.
186 \end{optionlst}
187 \end{optionitem}
188 \begin{optionitem}{nrows}{\optiondf{\{0\}}}
189 Specifies the number of rows in the table.
190 \end{optionitem}
191 \end{optiondetail}
192
193 \end{function}
194
195 \subsection{Selecting current table}
196
197 \begin{function}{\LPTSetCurrentTable}
198 \begin{syntax}
199 \cs{LPTSetCurrentTable} \Arg{table name}
200 \end{syntax}
201
202 For many subsequent commands, there is no need to specify \meta{table name} repeatedly: they fetch this information from a global variable. This macro sets the global variable for current table.
203 \end{function}
204
205 \begin{function}{\LPTGetCurrentTable}
206 \begin{syntax}
207 \cs{LPTGetCurrentTable}
208 \end{syntax}
209
210 Get the Lua-escaped name of current table.
211 \end{function}
212
213 \subsection{Modifying table rows}
214
215 \begin{function}{\LPTAddRow}
216
217 \begin{syntax}
218 \cs{LPTAddRow} \oarg{row options}
219 \end{syntax}
220
221 This command appends one more row to the current table. If an option is not specified in \meta{row options}, the default value is taken from \meta{table options} of the table.
222
223 \begin{optiondetail}{\meta{row options}}
224 \begin{optionitem}{before line}{\optiondf{\{\}}}
225 Specifies the line before this row.
226 \end{optionitem}
227 \begin{optionitem}{after line}{\optiondf{\{\}}}
228 Specifies the line after this row.
229 \end{optionitem}
230 \begin{optionitem}{after spacing}{\optiondf{\{\}}}
231 Specifies the extra spacing after this row.
232 \end{optionitem}
233 \end{optiondetail}
234
235 \end{function}
236
237
238 \begin{function}{\LPTSetRowProp}
239
240 \begin{syntax}
241 \cs{LPTSetRowProp} \Arg{index expr} \Arg{row options}
242 \end{syntax}
243
244 This command modifies the properties of rows specified in \meta{index expr}. In this case, \meta{index expr} can point to multiple rows. For example, the index expression |:3,4,6| will trigger the modification of 5 rows, namely row 1, 2, 3, 4 and 6.
245
246 \begin{optiondetail}{\meta{row options}}
247 \begin{optionitem}{before line}{\optiondf{\{\}}}
248 Specifies the line before this row.
249 \end{optionitem}
250 \begin{optionitem}{after line}{\optiondf{\{\}}}
251 Specifies the line after this row.
252 \end{optionitem}
253 \begin{optionitem}{after spacing}{\optiondf{\{\}}}
254 Specifies the extra spacing after this row.
255 \end{optionitem}
256 \end{optiondetail}
257
258 \end{function}
259
260 \subsection{Modifying table contents}
261
262 \begin{environment}{lptview}
263
264 \begin{syntax}
265 |\begin{lptview}| \Arg{index expr}
266 \Arg{view expr}
267 |\end{lptview}|
268 \end{syntax}
269
270 This environment creates a sub-view of current table. The sub-view region is specified by \meta{index expr}, and the content of this sub-view is specified by \meta{view expr}. The index expression should always consist of two components, where the first defines the range of rows and the second defines the range of columns.
271 \end{environment}
272
273
274 \begin{environment}{lptfill}
275
276 \begin{syntax}
277 |\begin{lptfill}| \Arg{index expr}
278 \Arg{content}
279 |\end{lptfill}|
280 \end{syntax}
281
282 This environment fills table region specified by \meta{index expr} with \meta{content}. When \meta{index expr} is empty, the entire table is filled. Even when \meta{index expr} is empty, the braces surrounding it cannot be abbreviated.
283
284 \end{environment}
285
286 \subsection{Using table source}
287
288 \begin{function}{\LPTUseTable}
289
290 \begin{syntax}
291 \cs{LPTUseTable}
292 \end{syntax}
293
294 Reads the source of current table into input stream.
295
296 \end{function}
297
298 \subsection{Deleting existing tables}
299
300 \begin{function}{\LPTDeleteTable}
301
302 \begin{syntax}
303 \cs{LPTDeleteTable} \Arg{table name}
304 \end{syntax}
305
306 Remove a table from Lua storage to save memory.
307
308 \end{function}
309
310 \section{Advanced Usage}
311
312 \subsection{Internal design}
313
314 In Lua, each cell is a \emph{class} with three attributes: |data|, |shape| and |parent|. Apparently, |data| holds the content of the cell. By default, the |shape| of all cells is |{1,1}|; the parent of all cells is |nil|. When there is a cell that spans multiple rows/columns, the top-left cell will be considered \emph{parent cell}, and the remaining cells in the region would have |shape| set to |nil| and |parent| set to the coordinates of parent cell.
315
316 \subsection{Programmatic interface}
317
318 The following macros allow one to access and modify table cells programmatically.
319
320 \begin{function}{\LPTSetCell}
321
322 \begin{syntax}
323 \cs{LPTSetCell} \Arg{index expr} \oarg{shape} \Arg{content}
324 \end{syntax}
325
326 Set the content of the cell specified in \meta{index expr} to \meta{content}. The index expression should always consist of two components, where each component only points to one integer. The shape is given by |<row span>, <column span>|. By default, the shape of a cell is |1,1|. When a cell occupies more then one cell space, the shape of its children cells will be set to |nil| automatically.
327
328 \begin{authornote}
329 \cs{LPTSetCell} is not completely identical to \env{lptview}. More concretely, \env{lptview} and \env{lptfill} override \LuaLaTeX 's |process_input_buffer| callback, which allows Lua side to receive verbatim content as is. However, the \meta{content} of \cs{LPTSetCell} needs to be processed by \cs{tl_to_str:n} before being passed to Lua. While the outcome is the same most of the time, \cs{tl_to_str:n} does append an empty space after macros, which stops verbatim commands from working properly.
330 \end{authornote}
331
332 \end{function}
333
334 \begin{function}{\LPTFill}
335 \begin{syntax}
336 \cs{LPTFill} \Arg{index expr} \Arg{content}
337 \end{syntax}
338
339 Fills table region specified by \meta{index expr} with \meta{content}. When \meta{index expr} is empty, the entire table is filled.
340
341 \end{function}
342
343 \begin{function}{\LPTGetTableNames}
344 \begin{syntax}
345 \cs{LPTGetTableNames}
346 \end{syntax}
347
348 Returns a comma-separated string containing the names of all tables.
349 \end{function}
350
351 \begin{function}{\LPTGetTableShape}
352 \begin{syntax}
353 \cs{LPTGetTableShape}
354 \end{syntax}
355
356 Returns the shape of the current table as a token list string. The number of rows is stored in first group; the number of columns is stored in second group.
357 \end{function}
358
359 \begin{function}{\LPTGetCellData}
360 \begin{syntax}
361 \cs{LPTGetCellData} \Arg{index expr}
362 \end{syntax}
363
364 Returns the data of the cell specified by \meta{index expr}.
365 \end{function}
366
367 \begin{function}{\LPTGetCellShape}
368 \begin{syntax}
369 \cs{LPTGetCellShape} \Arg{index expr}
370 \end{syntax}
371
372 Returns the shape of the cell specified by \meta{index expr} as a token list string. The number of rows is stored in first group; the number of columns is stored in second group. When the shape is |nil|, the macro returns |\c_novalue_tl|.
373 \end{function}
374
375 \begin{function}{\LPTGetCellParent}
376 \begin{syntax}
377 \cs{LPTGetCellParent} \Arg{index expr}
378 \end{syntax}
379
380 Returns the coordinates of the parent of the cell specified by \meta{index expr} as a token list string. The row index is stored in first group; the column index is stored in second group. When the parent is |nil|, the macro returns |\c_novalue_tl|.
381 \end{function}
382
383 \section{Examples}
384
385 \subsection{Creating and filling a table}
386
387 \begin{tablesample}
388 \LPTNewTable{oruVVAVhbMD0}{3}{|c|c|c|}[
389 default after line=\hline,
390 nrows=3]
391 \LPTSetCurrentTable{oruVVAVhbMD0}
392 \LPTSetRowProp{1}{before line=\hline}
393 \begin{lptfill}{}
394 \verb|#&_^|
395 \end{lptfill}
396 \LPTUseTable
397 \end{tablesample}
398
399
400 \subsection{Changing sub-table}
401
402 \begin{tablesample}
403 \LPTNewTable{IAs5OwqBcv0R}{4}{|c|c|c|c|}[
404 default after line=\cline{2-4},
405 nrows=4]
406 \LPTSetCurrentTable{IAs5OwqBcv0R}
407 \LPTFill{:-2,:-2}{Lorem}
408 \LPTFill{-1,2:-2}{Sit}
409 \LPTFill{:,-1}{Dolor}
410 \LPTSetRowProp{1}{before line=\hline}
411 \LPTSetRowProp{-1}{after line=\hline}
412 \begin{lptview}{:, 1}
413 { \multirow{4}{*}{\rotatebox{90}{Ipsum}} }[|4] \\ \\ \\
414 \end{lptview}
415 \LPTUseTable
416 \end{tablesample}
417
418 \begin{tablesample}
419 \LPTNewTable{4Fz0h0ES2zU9}{6}{|c|c|c|c|c|c|}[
420 default after line=\hline,
421 nrows=6]
422 \LPTSetCurrentTable{4Fz0h0ES2zU9}
423 \begin{lptfill}{}
424 \verb|Lorem|
425 \end{lptfill}
426 \LPTSetRowProp{1}{before line=\hline}
427 \LPTSetRowProp{3}{after line=\cline{1-2}\cline{5-6}}
428 \begin{lptview}{3:4, 3:4}
429 { \multicolumn{2}{c|}{\multirow{2}{*}{Ipsum}} }[-2]\\
430 { \multicolumn{2}{c|}{} }[-2]
431 \end{lptview}
432 \LPTUseTable
433 \end{tablesample}
434
435 \subsection{Modifying row spacing}
436
437 \begin{tablesample}
438 \LPTNewTable{KSDJ4C6wUgXL}{4}{|c|c|c|c|}[
439 default after line=\hline,
440 nrows=4]
441 \LPTSetCurrentTable{KSDJ4C6wUgXL}
442 \LPTFill{}{$\int_a^b f(x) dx$}
443 \LPTSetRowProp{1}{before line=\hline}
444 \LPTSetRowProp{-2:-1}{after spacing=1em}
445 \LPTUseTable
446 \end{tablesample}
447
448 \subsection{Sequentially constructing a table}
449
450 \begin{tablesample}
451 \LPTNewTable{yTvLL6PEYgoE}{3}{ccc}
452 \LPTSetCurrentTable{yTvLL6PEYgoE}
453 \LPTAddRow[before line=\toprule, after line=\midrule]
454 \begin{lptview}{-1,:}
455 {Field 1} {Field 2} {Field 3}
456 \end{lptview}
457 \LPTAddRow
458 \begin{lptview}{-1,:}
459 {Data 1} {Data 2} {Data 3}
460 \end{lptview}
461 \LPTAddRow[after line=\bottomrule]
462 \begin{lptview}{-1,:}
463 {Data 4} {\multicolumn{2}{c}{Data 5}}[-2]
464 \end{lptview}
465 \LPTUseTable
466 \end{tablesample}
467
468 \subsection{Change the color of cells based on value}
469
470 \begin{tablesample}
471 \LPTNewTable{hJXHnablQ14y}{8}{cccccccc}[nrows=8]
472 \LPTSetCurrentTable{hJXHnablQ14y}
473 \begin{lptview}{:,:}
474 {20} {90} {43} {36} {73} {72} {77} {68} \\
475 {60} {48} {41} {52} {39} {31} {90} {65} \\
476 {81} {47} {58} {62} {67} {35} {49} {51} \\
477 {85} {41} {59} {69} {46} {77} {46} {39} \\
478 {24} {64} {69} {64} {89} {90} {64} {67} \\
479 {27} {75} {47} {40} {43} {63} {29} {27} \\
480 {86} {21} {40} {79} {55} {40} {36} {40} \\
481 {71} {63} {65} {53} {74} {58} {75} {63}
482 \end{lptview}
483 \ExplSyntaxOn
484 \int_step_inline:nn {8} {
485 \int_step_inline:nn {8} {
486 \str_set:Nx \l_tmpa_str {\LPTGetCellData{#1,##1}}
487 \tl_set:Nx \l_tmpa_tl {\int_eval:n {100 - \l_tmpa_str}}
488 \str_set:Nx \l_tmpb_str {\exp_not:N\cellcolor{black!\l_tmpa_str}
489 \exp_not:N\color{blue!\l_tmpa_tl}\l_tmpa_str}
490 \exp_args:Nno \LPTSetCell {#1,##1} {\l_tmpb_str}
491 }
492 }
493 \ExplSyntaxOff
494 \LPTUseTable
495 \end{tablesample}
496
497 \subsection{Listing the name and shape of all tables}
498
499
500 \begin{tablesample}
501 \ExplSyntaxOn
502 \clist_set:Nx \l_tmpa_clist {\LPTGetTableNames}
503 \LPTNewTable{oOnXsQcb7f8j}{2}{cc}
504 \LPTSetCurrentTable{oOnXsQcb7f8j}
505 \LPTAddRow
506 \begin{lptview}{1,:}
507 {Table~Name} {Shape}
508 \end{lptview}
509 \clist_map_inline:Nn \l_tmpa_clist {
510 \LPTAddRow
511 \LPTSetCell{-1,1}{\texttt{#1}}
512 \LPTSetCurrentTable{#1}
513 \tl_set:Nx \l_tmpa_tl {\LPTGetTableShape}
514 \LPTSetCurrentTable{oOnXsQcb7f8j}
515 \tl_set:Nx \l_tmpb_tl {$(\tl_item:Nn \l_tmpa_tl {1},
516 \tl_item:Nn \l_tmpa_tl {2})$}
517 \exp_args:Nno \LPTSetCell {-1,2} {\l_tmpb_tl}
518 }
519 \LPTSetRowProp{1}{before~line=\toprule, after~line=\midrule}
520 \LPTSetRowProp{-1}{after~line=\bottomrule}
521 \LPTUseTable
522 \ExplSyntaxOff
523 \end{tablesample}
524
525 \section{Test cases}
526
527 \subsection*{Testing robustness of table modification}
528
529 \begin{tablesample}
530 \LPTNewTable{mnEfCpDkN3OL}{6}{|c|c|c|c|c|c|}[
531 default after line=\hline,
532 nrows=6]
533 \LPTSetCurrentTable{mnEfCpDkN3OL}
534 \begin{lptfill}{}
535 \verb|Lorem|
536 \end{lptfill}
537 \LPTSetRowProp{1}{before line=\hline}
538 \LPTSetRowProp{3}{after line=\cline{1-2}\cline{5-6}}
539 \begin{lptview}{3:4, 3:4}
540 { \multicolumn{2}{c|}{\multirow{2}{*}{Ipsum}} }[-2]\\
541 { \multicolumn{2}{c|}{} }[-2]
542 \end{lptview}
543 \LPTUseTable\par\vspace*{1em}
544 \begin{lptview}{3:4, 3:4}
545 { \multicolumn{2}{c|}{Change} }[-2]\\
546 { \multicolumn{2}{c|}{Change} }[-2]
547 \end{lptview}
548 \LPTUseTable\par\vspace*{1em}
549 \begin{lptview}{3:4, 3:4}
550 {A} {B}\\
551 {C} {D}
552 \end{lptview}
553 \LPTUseTable
554 \end{tablesample}
555
556
557 \begin{tablesample}
558 \LPTNewTable{869CviFSrnEy}{6}{|c|c|c|c|c|c|}[
559 default after line=\hline,
560 nrows=6]
561 \LPTSetCurrentTable{869CviFSrnEy}
562 \begin{lptfill}{}
563 \verb|Lorem|
564 \end{lptfill}
565 \LPTSetRowProp{1}{before line=\hline}
566 \LPTSetRowProp{3}{after line=\cline{1-2}\cline{5-6}}
567 \LPTSetCell{3,3}[1,2]{\multicolumn{2}{c|}{\multirow{2}{*}{Ipsum}}}
568 \LPTSetCell{4,3}[1,2]{\multicolumn{2}{c|}{}}
569 \LPTUseTable\par\vspace*{1em}
570 \LPTSetCell{3,3}[1,2]{\multicolumn{2}{c|}{Change}}
571 \LPTSetCell{4,3}[1,2]{\multicolumn{2}{c|}{Change}}
572 \LPTUseTable\par\vspace*{1em}
573 Notice how \verb|Lorem| appears because we haven't changed
574 the values of cell $(3,4)$ and $(4,4)$.\par
575 \LPTSetCell{3,3}{A}
576 \LPTSetCell{4,3}{C}
577 \LPTUseTable\par\vspace*{1em}
578 \end{tablesample}
579
580 \subsection*{Testing other functions}
581
582 \begin{tablesample}
583 \LPTNewTable{kCYKq42SyQtf}{5}{|c|c|c|c|c|}[
584 default after line=\hline,
585 nrows=6]
586 \LPTSetCurrentTable{kCYKq42SyQtf}
587 \LPTSetRowProp{1}{before line=\hline}
588 \ExplSyntaxOn
589 \int_step_inline:nn {6} {
590 \int_step_inline:nn {5} {
591 \tl_set:Nx \l_tmpa_tl {\LPTGetCellShape{#1,##1}}
592 \tl_set:Nx \l_tmpb_tl {shape=\tl_item:Nn \l_tmpa_tl {1},
593 \tl_item:Nn \l_tmpa_tl {2}}
594 \exp_args:Nno \LPTSetCell {#1,##1} {\l_tmpb_tl}
595 }
596 }
597 \ExplSyntaxOff
598 \LPTUseTable\par\vspace*{1em}
599 \ExplSyntaxOn
600 \int_step_inline:nn {6} {
601 \int_step_inline:nn {5} {
602 \tl_set:Nx \l_tmpa_tl {\LPTGetCellParent{#1,##1}}
603 \tl_if_eq:NNTF \l_tmpa_tl \c_novalue_tl {
604 \LPTSetCell {#1,##1} {NoP}
605 }{
606 \LPTSetCell {#1,##1} {HasP}
607 }
608 }
609 }
610 \LPTUseTable
611 \ExplSyntaxOff
612 \end{tablesample}
613
614 \end{documentation}
615
616 \end{document}