Debian Codegraph @

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

raw
1 \documentclass{article}
2 \usepackage{listings,color,parskip,booktabs,longtable,array,
3 hyperref,multirow,multicol,enumitem}
4 \usepackage[top=1.1in, bottom=1.1in, left=1in, right=1in]{geometry}
5 \hypersetup{colorlinks,urlcolor=blue}
6 \lstset{frame=none,
7 language=[LaTeX]{TeX},
8 aboveskip=3mm,
9 belowskip=3mm,
10 showstringspaces=false,
11 columns=flexible,
12 basicstyle={\ttfamily},
13 numbers=none,
14 numberstyle=\tiny\color{gray},
15 stringstyle=\color{mauve},
16 breaklines=true,
17 breakatwhitespace=true,
18 tabsize=1
19 }
20 \usepackage{microtype,graphicx,amsmath,amssymb,float}
21 \usepackage[backend=bibtex]{biblatex}
22 \addbibresource{luamodular}
23 \begin{document}
24 \title{The luamodulartables Package in LaTeX}
25 \author{Chetan Shirore\thanks{Email id: [email protected]} \space and Ajit Kumar}
26 \maketitle
27 \section{Introduction}\label{section:introduction}
28 The \verb|luamodulartables| package is developed to generate modular addition and multiplication tables for positive integers. It provides an easy way to generate modular addition and modular multiplication tables for positive integers in LaTeX documents. The commands in the package have optional arguments for the formatting of tables. These commands can be used in an environment similar to a \verb|tabular| or \verb|array| environment. The commands can also be used with the \verb|booktabs| package, which provides nice formatting of tables in LaTeX. It is written in Lua, and TeX file is to be compiled with LuaLaTeX engine.
29
30
31 The Lua \cite{online.luaorg} programming language is a scripting language that can be embedded across platforms. With\verb|LuaTeX| \cite{online.luatex} and\verb|luacode| \cite{online.luacode} packages, it is possible to use Lua in LaTeX. The TeX \cite{online.tex} or LaTeX has scope for programming \cite{online.texscript}. However, with the weird internals of TeX, there are several limitations, especially for performing calculations on numbers in LaTeX documents. There are packages like \emph{pgf} \cite{online.pgf} and \emph{xparse} \cite{online.xparse} in LaTeX which provides some programming capabilities inside LaTeX documents. However, such packages do not provide the complete programming structure that Lua programming languages provide. The \verb|luacode| \cite{online.luacode} package is used in its development apart from the \verb|luacode| package. The time required to generate modulo addition and multiplication tables is not an issue while compiling with LuaLaTeX. There is no need to install Lua on users system as TeX distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. The package can be modified or extended by writing custom Lua programs.
32
33 The modular addition (multiplication) of integers with respect to positive integer \(n\) is obtained by taking the remainder of the usual addition (multiplication) after dividing it by\(n\). There is no easy way in LaTeX to do modular addition and multiplication \cite{online.modularithmetic}. With Lua, it can be achieved easily in LaTeX. Also, non-Lua ways of doing modular arithmetic in LaTeX are more complicated \cite{online.modularithmetic2}.
34
35 \section{Installation and License}
36
37 The installation of \verb|luamodulartables| package is similar to plain latex package, where the \texttt{.sty} file is in \LaTeX directory of texmf tree. The package can be included with \verb|\usepackage{luamodulartables}| command in the preamble of the LaTeX document. The TeX file is to be compiled using the LuaLaTeX engine.
38
39
40 The \verb|luamodulartables| package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at \url{http://www.latex-project.org/lppl.txt}. It is developed in Lua. Lua is available as a certified open-source software. Its license is simple and liberal, which is compatible with GPL.
41
42 \section{Commands in the luamodulartables package}
43 The \texttt{luaModularMult} and \texttt{luaModularAdd} are two commands available in the \verb|luamodulartables| package. The subsections of this section provide detailed descriptions of these commands.
44 \subsubsection{luaModularMult command}
45 The command \verb|luaModularMult| has the following syntax.
46 \begin{verbatim}
47 \verb|\luaModularMult[multlabel,headline,midline]{n}|
48 \end{verbatim}
49 This command has \texttt{multlabel, headline}, and \texttt{midline} as its optional arguments and has one compulsory argument \verb|n|. The \verb|multlabel| denotes the label to be printed at the entry in the first row and first column of the tabular environment. Its default value is \verb|$\times$|. The \verb|headline| refers to the style of a horizontal line after the first row in a tabular or table environment. The \verb|midline| refers to the style of horizontal lines after the second row till the second last row. The default values of the \verb|headline| and \verb|midline| are \emph{none}. The formatting of the top line (before the beginning of the first row) and bottom line (after the end of the last row) is available at the user end in the LaTeX document. The reference for these commands is given in Figure \ref{fig:luaModularMult}. Also, the alignment of columns and vertical lines for columns are available at the user end. The compulsory argument denotes the positive integer \(n\) with respect to which modular multiplication is to be carried out.
50
51
52 \begin{figure}[!ht] % or [H] to turn off float
53 \centering
54 \includegraphics[scale=0.273]{luaModularMult.jpg}
55 \caption{Optional arguments in luaModularMult command}
56 \label{fig:luaModularMult}
57 \end{figure}
58
59 \subsubsection{Illustration of luaModularMult command}This section illustrates the use of \verb|\luaModularMult| command with several examples.
60 \begin{lstlisting}[caption={Illustration 1 of luaModularMult command} ,label={luamodmult1}]
61 \begin{tabular}{r|rrrrrrrrr}
62 \luaModularMult{9}
63 \end{tabular}
64 \end{lstlisting}
65
66 The LaTeX code in listing \ref{luamodmult1} generates the output shown in Table \ref{luamodmult1tbl}.
67
68
69 \begin{table}[H]
70 \centering
71 \begin{tabular}{r|rrrrrrrrr}
72 $\times$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\ $1$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $2$ & $0$ & $2$ & $4$ & $6$ & $8$ & $1$ & $3$ & $5$ & $7$\\ $3$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$\\ $4$ & $0$ & $4$ & $8$ & $3$ & $7$ & $2$ & $6$ & $1$ & $5$\\ $5$ & $0$ & $5$ & $1$ & $6$ & $2$ & $7$ & $3$ & $8$ & $4$\\ $6$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$\\ $7$ & $0$ & $7$ & $5$ & $3$ & $1$ & $8$ & $6$ & $4$ & $2$\\ $8$ & $0$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$
73 \end{tabular}
74 \caption{Illustration 1 of luaModularMult command}
75 \label{luamodmult1tbl}
76 \end{table}
77
78 Let us see some more examples of \verb|\luaModularMult| command with optional arguments.
79 \begin{lstlisting}[caption={Illustration 2 of luaModularMult command} ,label={luamodmult2}]
80 \begin{tabular}{r|rrrrrrrrr}
81 \luaModularMult[headline=\hline]{9}
82 \end{tabular}
83 \end{lstlisting}
84 The LaTeX code in listing \ref{luamodmult2} generates the output shown in Table \ref{luamodmult2tbl}. Here the style of \verb|headline| is specified as \verb|\hline|.
85
86 \begin{table}[H]
87 \centering
88 \begin{tabular}{r|rrrrrrrrr}
89 $\times$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline$0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\ $1$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $2$ & $0$ & $2$ & $4$ & $6$ & $8$ & $1$ & $3$ & $5$ & $7$\\ $3$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$\\ $4$ & $0$ & $4$ & $8$ & $3$ & $7$ & $2$ & $6$ & $1$ & $5$\\ $5$ & $0$ & $5$ & $1$ & $6$ & $2$ & $7$ & $3$ & $8$ & $4$\\ $6$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$\\ $7$ & $0$ & $7$ & $5$ & $3$ & $1$ & $8$ & $6$ & $4$ & $2$\\ $8$ & $0$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$
90 \end{tabular}
91 \caption{Illustration 2 of luaModularMult command}
92 \label{luamodmult2tbl}
93 \end{table}
94
95 \begin{lstlisting}[caption={Illustration 3 of luaModularMult command} ,label={luamodmult3}]
96 \begin{tabular}{r|rrrrrrrrr}
97 \luaModularMult[headline=\hline,midline=\hline]{9}
98 \end{tabular}
99 \end{lstlisting}
100 The LaTeX code in listing \ref{luamodmult3} generates the output shown in Table \ref{luamodmult3tbl}. Here the style of \verb|headline| and \verb|midline| is specified as \verb|\hline|.
101
102 \begin{table}[H]
103 \centering
104 \begin{tabular}{r|rrrrrrrrr}
105 $\times$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline$0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\ \hline$1$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline$2$ & $0$ & $2$ & $4$ & $6$ & $8$ & $1$ & $3$ & $5$ & $7$\\ \hline$3$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$\\ \hline$4$ & $0$ & $4$ & $8$ & $3$ & $7$ & $2$ & $6$ & $1$ & $5$\\ \hline$5$ & $0$ & $5$ & $1$ & $6$ & $2$ & $7$ & $3$ & $8$ & $4$\\ \hline$6$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$\\ \hline$7$ & $0$ & $7$ & $5$ & $3$ & $1$ & $8$ & $6$ & $4$ & $2$\\ \hline$8$ & $0$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$
106 \end{tabular}
107 \caption{Illustration 3 of luaModularMult command}
108 \label{luamodmult3tbl}
109 \end{table}
110
111
112 In the following example, the formatting of the top line (before the beginning of the first row) and bottom line (after the end of the last row) are given in TeX document explicitly, and the style of the \verb|headline| and \verb|midline| is specified as \verb|\hline| through optional arguments of the command \verb|\luaModularMult|.
113 \begin{lstlisting}[caption={Illustration 4 of luaModularMult command} ,label={luamodmult4}]
114 \begin{tabular}{r|rrrrrrrrr}
115 \hline
116 \luaModularMult[headline=\hline]{9} \\
117 \hline
118 \end{tabular}
119 \end{lstlisting}
120 The LaTeX code in listing \ref{luamodmult4} generates the output shown in Table \ref{luamodmult4tbl}.
121
122 \begin{table}[H]
123 \centering
124 \begin{tabular}{r|rrrrrrrrr}
125 \hline
126 $\times$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline$0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\ $1$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $2$ & $0$ & $2$ & $4$ & $6$ & $8$ & $1$ & $3$ & $5$ & $7$\\ $3$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$\\ $4$ & $0$ & $4$ & $8$ & $3$ & $7$ & $2$ & $6$ & $1$ & $5$\\ $5$ & $0$ & $5$ & $1$ & $6$ & $2$ & $7$ & $3$ & $8$ & $4$\\ $6$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$\\ $7$ & $0$ & $7$ & $5$ & $3$ & $1$ & $8$ & $6$ & $4$ & $2$\\ $8$ & $0$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$ \\
127 \hline
128 \end{tabular}
129
130 \caption{Illustration 4 of luaModularMult command}
131 \label{luamodmult4tbl}
132 \end{table}
133
134 The \verb|booktabs| package can be used for beautifying tables. The following piece of code illustrates this.
135 \begin{lstlisting}[caption={Illustration 5 of luaModularMult command} ,label={luamodmult5}]
136 \begin{tabular}{r|rrrrrrrrr}
137 \toprule
138 \luaModularMult[headline=\midrule]{9} \\
139 \bottomrule
140 \end{tabular}
141 \end{lstlisting}
142 The LaTeX code in listing \ref{luamodmult5} generates the output shown in Table \ref{luamodmult5tbl}.
143 \begin{table}[H]
144 \centering
145 \begin{tabular}{r|rrrrrrrrr}
146 \toprule
147 $\times$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \midrule $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\ $1$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $2$ & $0$ & $2$ & $4$ & $6$ & $8$ & $1$ & $3$ & $5$ & $7$\\ $3$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$\\ $4$ & $0$ & $4$ & $8$ & $3$ & $7$ & $2$ & $6$ & $1$ & $5$\\ $5$ & $0$ & $5$ & $1$ & $6$ & $2$ & $7$ & $3$ & $8$ & $4$\\ $6$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$\\ $7$ & $0$ & $7$ & $5$ & $3$ & $1$ & $8$ & $6$ & $4$ & $2$\\ $8$ & $0$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$ \\
148 \bottomrule
149 \end{tabular}
150 \caption{Illustration 5 of luaModularMult command}
151 \label{luamodmult5tbl}
152 \end{table}
153
154 As the last illustration, the optional parameter \verb|multlabel| is specified in \verb|\luaModularMult| command. It needs the \verb|amsmath| and \verb|amssymb| package for successful compilation.
155 \begin{lstlisting}[caption={Illustration 6 of luaModularMult command} ,label={luamodmult6}]
156 \begin{tabular}{r|rrrrrrrrr}
157 \toprule
158 \luaModularMult[multlabel=$\mathbb{Z}_9$,headline=\midrule]{9} \\
159 \bottomrule
160 \end{tabular}
161 \end{lstlisting}
162 The LaTeX code in listing \ref{luamodmult6} generates the output shown in Table \ref{luamodmult6tbl}.
163 \begin{table}[H]
164 \centering
165 \begin{tabular}{r|rrrrrrrrr}
166 \toprule
167 $\mathbb{Z}_9$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \midrule $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$\\ $1$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $2$ & $0$ & $2$ & $4$ & $6$ & $8$ & $1$ & $3$ & $5$ & $7$\\ $3$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$ & $0$ & $3$ & $6$\\ $4$ & $0$ & $4$ & $8$ & $3$ & $7$ & $2$ & $6$ & $1$ & $5$\\ $5$ & $0$ & $5$ & $1$ & $6$ & $2$ & $7$ & $3$ & $8$ & $4$\\ $6$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$ & $0$ & $6$ & $3$\\ $7$ & $0$ & $7$ & $5$ & $3$ & $1$ & $8$ & $6$ & $4$ & $2$\\ $8$ & $0$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$\\
168 \bottomrule
169 \end{tabular}
170 \caption{Illustration 6 of luaModularMult command}
171 \label{luamodmult6tbl}
172 \end{table}
173
174
175 \subsubsection{luaModularAdd command}
176 The commands \verb|luaModularAdd| has the following syntax.
177 \begin{verbatim}
178 \luaModularAdd[addlabel,headline,midline]{n}
179 \end{verbatim}
180 This command has \verb|addlabel|, \verb|headline| and \verb|midline| as its optional arguments and one compulsory argument \verb|n|. The \verb|addlabel| denotes the label to be printed at the entry in the first row and first column of the tabular environment. Its default value is \verb|$+$|. The \verb|headline| refers to the style of a horizontal line after thr first row in a tabular or table environment. The \verb|midline| refers to the style of horizontal lines after the second row till the second last row. The default values of the \verb|headline| and \verb|midline| are \emph{none}. The reference for these commands is given in Figure \ref{fig:luamodularadd}. Also, the alignment of columns and vertical lines between columns are available at the user end. The formatting of the top line (before the beginning of the first row) and bottom line (after the end of the last row) is available at the user end in the LaTeX document. Also, the alignment of columns is available at user end. The compulsory argument denotes the positive integer \(n\) with respect to which modular multiplication is to be carried out.
181
182 \begin{figure}[!ht] % or [H] to turn off float
183 \centering
184 \includegraphics[scale=0.27]{luamodularadd.jpg}
185 \caption{Optional arguments in luaModularAdd command}
186 \label{fig:luamodularadd}
187 \end{figure}
188 \subsubsection{Illustration of luaModularAdd command }
189 This section illustrates the use of \verb|\luaModularAdd| command with several examples.
190 \begin{lstlisting}[caption={Illustration 1 of luaModularAdd command} ,label={luamodadd1}]
191 \begin{tabular}{r|rrrrrrrrr}
192 \luaModularAdd{9}
193 \end{tabular}
194 \end{lstlisting}
195
196 The LaTeX code in listing \ref{luamodadd1} generates the output shown in Table \ref{luamodadd1tbl}.
197 \begin{table}[H]
198 \centering
199 \begin{tabular}{r|rrrrrrrrr}
200 $+$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\ $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\ $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\ $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\ $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\ $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\ $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\ $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$
201 \end{tabular}
202 \caption{Illustration 1 of luaModularAdd command}
203 \label{luamodadd1tbl}
204 \end{table}
205
206
207 The following code is generated by the command \verb|\luaModularAdd{9}|.
208 \begin{lstlisting}
209 $+$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
210 $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
211 $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\
212 $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\
213 $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\
214 $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\
215 $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\
216 $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\
217 $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\
218 $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$
219 \end{lstlisting}
220 Let us see some more examples of \verb|\luaModularAdd| command with optional arguments.
221 \begin{lstlisting}[caption={Illustration 2 of luaModularAdd command} ,label={luamodadd2}]
222 \begin{tabular}{r|rrrrrrrrr}
223 \luaModularAdd[headline=\hline]{9}
224 \end{tabular}
225 \end{lstlisting}
226 The LaTeX code in listing \ref{luamodadd2} generates the output shown in Table \ref{luamodadd2tbl}. Here the style of \verb|headline| is specified as \verb|\hline|.
227
228 \begin{table}[H]
229 \centering
230 \begin{tabular}{r|rrrrrrrrr}
231 $+$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\ $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\ $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\ $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\ $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\ $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\ $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\ $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$
232 \end{tabular}
233 \caption{Illustration 2 of luaModularAdd command}
234 \label{luamodadd2tbl}
235 \end{table}
236
237 \begin{lstlisting}[caption={Illustration 3 of luaModularAdd command} ,label={luamodadd3}]
238 \begin{tabular}{r|rrrrrrrrr}
239 \luaModularAdd[headline=\hline,
240 midline=\hline]{9}
241 \end{tabular}
242 \end{lstlisting}
243 The LaTeX code in listing \ref{luamodadd3} generates the output shown in Table \ref{luamodadd3tbl}. Here the style of the \verb|headline| and \verb|midline| is specified as \verb|\hline|.
244
245 \begin{table}[H]
246 \centering
247 \begin{tabular}{r|rrrrrrrrr}
248 $+$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \hline $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\ \hline $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\ \hline $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\ \hline $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\ \hline $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\ \hline $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\ \hline $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\ \hline $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$
249 \end{tabular}
250 \caption{Illustration 3 of luaModularAdd command}
251 \label{luamodadd3tbl}
252 \end{table}
253
254 In the following example, the formatting of the top line (before the beginning of the first row) and bottom line (after the end of the last row) are given in TeX document explicitly, and the style of the \verb|headline| and \verb|midline| is specified as \verb|\hline| through optional arguments of the command \verb|\luaModularAdd|.
255 \begin{lstlisting}[caption={Illustration 4 of luaModularAdd command} ,label={luamodadd4}]
256 \begin{tabular}{r|rrrrrrrrr}
257 \hline
258 \luaModularMult[headline=\hline]{9} \\
259 \hline
260 \end{tabular}
261 \end{lstlisting}
262 The LaTeX code in listing \ref{luamodadd4} generates the output shown in Table \ref{luamodadd4tbl}.
263 \begin{table}[H]
264 \centering
265 \begin{tabular}{r|rrrrrrrrr}
266 \hline
267 $+$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
268 \hline $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
269 $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\
270 $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\
271 $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\
272 $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\
273 $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\
274 $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\
275 $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\
276 $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
277 \hline
278 \end{tabular}
279 \caption{Illustration 4 of luaModularAdd command}
280 \label{luamodadd4tbl}
281 \end{table}
282
283 The \verb|booktabs| package can be used for beautifying tables. The following piece of code illustrates this.
284 \begin{lstlisting}[caption={Illustration 5 of luaModularAdd command} ,label={luamodadd5}]
285 \begin{tabular}{r|rrrrrrrrr}
286 \toprule
287 \luaModularAdd[headline=\midrule]{9} \\
288 \bottomrule
289 \end{tabular}
290 \end{lstlisting}
291 The LaTeX code in listing \ref{luamodadd5} generates the output shown in Table \ref{luamodadd5tbl}.
292
293 \begin{table}[H]
294 \centering
295 \begin{tabular}{r|rrrrrrrrr}
296 \toprule
297 $+$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \midrule $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\ $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\ $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\ $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\ $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\ $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\ $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\ $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
298 \bottomrule
299 \end{tabular}
300 \caption{Illustration 5 of luaModularAdd command}
301 \label{luamodadd5tbl}
302 \end{table}
303
304 As the last illustration, the optional parameter \verb|addlabel| is specified in \verb|\luaModularAdd| command. If a more complex expression (especially involving a comma) is to be entered, it is better to enclose the code in curly braces as in the following example. The same rule applies to other keys as well. This needs the \verb|amsmath| and \verb|amssymb| package for successful compilation.
305 \begin{lstlisting}[caption={Illustration 6 of luaModularAdd command} ,label={luamodadd6}]
306 \begin{tabular}{r|rrrrrrrrr}
307 \toprule
308 \luaModularAdd[addlabel={$(\mathbb{Z}_9,+)$},headline=\midrule]{9} \\
309 \bottomrule
310 \end{tabular}
311 \end{lstlisting}
312 The LaTeX code in listing \ref{luamodadd6} generates the output shown in Table \ref{luamodadd6tbl}.
313 \begin{table}[H]
314 \centering
315 \begin{tabular}{r|rrrrrrrrr}
316 \toprule
317 $\mathbb{Z}_9$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ \midrule $0$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\ $1$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$\\ $2$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$\\ $3$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$\\ $4$ & $4$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$\\ $5$ & $5$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$\\ $6$ & $6$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$\\ $7$ & $7$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$\\ $8$ & $8$ & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
318 \bottomrule
319 \end{tabular}
320 \caption{Illustration 6 of luaModularAdd command}
321 \label{luamodadd6tbl}
322 \end{table}
323
324 \printbibliography
325 \end{document}