Debian Codegraph @

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

raw
1 \documentclass{article}
2 \usepackage{listings,color,booktabs,longtable,array,hyperref,multicol,framed}
3 \usepackage[ left=1in, right=1in]{geometry}
4 \hypersetup{colorlinks,urlcolor=blue}
5 \lstset{frame=none,
6 language=[LaTeX]{TeX},
7 aboveskip=3mm,
8 belowskip=3mm,
9 showstringspaces=false,
10 columns=flexible,
11 basicstyle={\ttfamily},
12 numbers=none,
13 numberstyle=\tiny\color{gray},
14 stringstyle=\color{mauve},
15 breaklines=true,
16 breakatwhitespace=true,
17 tabsize=1
18 }
19 \usepackage[backend=bibtex]{biblatex}
20 \begin{document}
21 \title{The luaset Package in LaTeX}
22 \author{Chetan Shirore\thanks{Email id: [email protected]} \space and Ajit Kumar}
23 \maketitle
24 \section{Introduction}\label{section:introduction}
25 The \verb|luaset| package is developed to define finite sets and perform operations on finite sets inside LaTeX documents. There is no particular environment in the package for performing set operations. The package commands can be used in any environment (including the mathematics environment). It is written in Lua, and tex file is to be compiled with the LuaLaTeX engine. The time required for performing set operations is not an issue while compiling with LuaLaTeX. There is no need to install Lua on the users' system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. The package is helps to perform set operations (union, intersection, difference, etcetera) in LaTeX documents. It may also save the users' efforts to copy sets from other software (which may not be in LaTeX compatible format) and to use them in a tex file. The package supports the nesting of commands for multiple operations.
26
27 \section{Installation and License}
28
29 The installation of the \verb|luaset| 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{luaset}| command in the preamble of the LaTeX document. The TeX file is to be compiled using the LuaLaTeX engine.
30
31 The \verb|luaset| 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. Questions on \url{https://tex.stackexchange.com} inspired a small part of the development of this package. The content on this site is available under the \verb|CC BY-SA| license. It also loads the \verb|luamaths| package, which is available under the LaTeX Project Public License v1.3c or later. This package is loaded to use the standard mathematical functions and computations on real numbers while performing operations on sets.
32
33 \subsection{Defining and Displaying Sets}
34 A set can be defined by using the \verb|\luaSetNew| command.
35 \begin{lstlisting}
36 \luaSetNew{name}{set}
37 \end{lstlisting}
38 The following commands define sets \( A \) and \(B \).
39 \begin{lstlisting}
40 \luaSetNew{A}{a,b,c,10,d,10,a,30}
41 \luaSetNew{B}{d,e,f,10,20}
42 \end{lstlisting}
43 The set can be displayed or printed by using the \verb|\luaSetPrint| command.
44 \begin{lstlisting}
45 \luaSetPrint{name of set}
46 \end{lstlisting}
47 For example, the following commands
48 \begin{lstlisting}
49 \(A = \luaSetPrint{A}\) \\
50 \(B = \luaSetPrint{B}\)
51 \end{lstlisting}
52 output to
53 \begin{framed}
54 \noindent \(A = \{10, 30, a, b, c, d\}\) \\
55 \(B = \{10, 20, d, e, f\}\)
56 \end{framed}
57 The standard mathematical functions can also be used.
58 \subsection{Commands in the luaset package}
59 Table \ref{tbl:opluaset} summarises commands in the \verb|luaset| package.
60 \begin{center}
61 \begin{longtable}{llm{5cm}}
62 \toprule
63 \multicolumn{1}{c}{\textcolor{blue}{Function}} & \multicolumn{1}{c}{\textcolor{blue}{Command Format}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\
64 \toprule
65 \begin{lstlisting}
66 \luaSetUnion
67 \end{lstlisting} &
68 \begin{lstlisting}
69 \luaSetUnion{set}{set1}{set2}
70 \end{lstlisting} & Defines the new set as a union of set1 and set2. \\
71 \midrule
72 \begin{lstlisting}
73 \luaSetIntersection
74 \end{lstlisting} &
75 \begin{lstlisting}
76 \luaSetIntersection{set}{set1}{set2}
77 \end{lstlisting} & Defines the new set as an intersection of set1 and set2. \\
78 \midrule
79 \begin{lstlisting}
80 \luaSetDifference
81 \end{lstlisting} &
82 \begin{lstlisting}
83 \luaSetDifference{set}{set1}{set2}
84 \end{lstlisting} & Defines the new set as a difference of set1 and set2. \\
85 \midrule
86 \begin{lstlisting}
87 \luaSetCardinal
88 \end{lstlisting} &
89 \begin{lstlisting}
90 \luaSetCardinal{set}
91 \end{lstlisting} & Gives the cardinality of a set (number of elements). \\
92 \midrule
93 \begin{lstlisting}
94 \luaSetBelongsto
95 \end{lstlisting} &
96 \begin{lstlisting}
97 \luaSetBelongsto{element}{set}
98 \end{lstlisting} & Returns true if an element is in a set; otherwise, it returns false.\\
99 \midrule
100 \begin{lstlisting}
101 \luaSetSubseteq
102 \end{lstlisting} &
103 \begin{lstlisting}
104 \luaSetSubseteq{set1}{set2}
105 \end{lstlisting} & Returns true if set1 is a subset of set2; otherwise, it returns false. \\
106 \midrule
107 \begin{lstlisting}
108 \luaSetSubset
109 \end{lstlisting} &
110 \begin{lstlisting}
111 \luaSetSubset{set1}{set2}
112 \end{lstlisting} & Returns true if set1 is a proper subset of set2; otherwise, it returns false. \\
113 \midrule
114 \begin{lstlisting}
115 \luaSetEqual
116 \end{lstlisting} &
117 \begin{lstlisting}
118 \luaSetEqual{set1}{set2}
119 \end{lstlisting} & Returns true if set1 is equal to set2; otherwise, it returns false. \\
120 \bottomrule
121 \caption{Commands in the luaset package}
122 \label{tbl:opluaset}
123 \end{longtable}
124 \end{center}
125 \subsection{Examples and Usage}
126 The latex document (Listing: \ref{code:illluaset}) uses various commands in the \verb|luaset| package.
127 \begin{lstlisting}[label={code:illluaset}, caption={LaTeX document with luaset package}]
128 \documentclass{article}
129 \usepackage{luaset,parskip}
130 \begin{document}
131 \luaSetNew{A}{a,b,c,\mathCos{0},d,10,a,30}
132 \luaSetNew{B}{d,e,f,10,20}
133 \luaSetUnion{C}{A}{B}
134 \luaSetIntersection{D}{A}{B}
135 \luaSetDifference{E}{A}{B}
136 \luaSetDifference{F}{B}{A}
137 \(A = \luaSetPrint{A}\) % printing set A
138
139 \(B = \luaSetPrint{B}\) % printing set B
140
141 \(C = A \cup B = \luaSetPrint{C}\) % printing set C
142
143 \(D = A\cap B = \luaSetPrint{D}\) % printing set D
144
145 \(E = A-B = \luaSetPrint{E}\) % printing set E
146
147 \(F = B-A = \luaSetPrint{F}\) % printing set F
148
149 The Cardinality of set \(A\) is \luaSetCardinal{A}.
150
151 It is \luaSetSubseteq{A}{B} that \(A \subseteq B \).
152
153 It is \luaSetSubseteq{A}{C} that \(A \subseteq C \).
154
155 It is \luaSetSubset{A}{B} that \(A \subset B \).
156
157 It is \luaSetSubset{A}{C} that \(A \subset C \).
158
159 \luaSetIntersection{G}{C}{A}
160
161 \(G = C \cap A = \luaSetPrint{G}\) % printing set G
162
163 It is \luaSetEqual{A}{B} that \(A=B \).
164
165 It is \luaSetEqual{G}{A} that \(G=A \).
166
167 It is \luaSetBelongsto{z}{A} that \(z \in A \).
168
169 It is \luaSetBelongsto{10}{A} that \(10 \in A \).
170
171 \luaSetNew{S}{a,10,b,x,y,z,100,200}
172
173 \(S = \luaSetPrint{S}\) % printing set S
174
175
176 \luaSetIntersection{H}{C}{S}
177 \luaSetUnion{I}{D}{S}
178
179 \(H = C \cap S = \luaSetPrint{H}\) % printing set H
180
181 \(I = D \cup S = \luaSetPrint{I}\) % printing set I
182 \end{document}
183 \end{lstlisting}
184 The latex document (Listing: \ref{code:illluaset}) generates the following output on the compilation.
185
186 \begin{framed}
187
188 \(A = \{10, 30, 1.0, a, b, c, d\}\) % printing set A
189
190 \(B =\{10, 20, d, e, f\}\) % printing set B
191
192 \(C = A \cup B = \{10, 20, 30, 1.0, a, b, c, d, e, f\}\) % printing set C
193
194 \(D = A\cap B = \{10, d\}\) % printing set D
195
196 \(E = A-B = \{30, 1.0, a, b, c\}\) % printing set E
197
198 \(F = B-A = \{20, e, f\}\) % printing set F
199
200 The Cardinality of set \(A\) is 7.
201
202 It is false that \(A \subseteq B \).
203
204 It is true that \(A \subseteq C \).
205
206 It is false that \(A \subset B \).
207
208 It is true that \(A \subset C \).
209
210 \(G = C \cap A = \{10, 30, 1.0, a, b, c, d\}\) % printing set G
211
212 It is false that \(A=B \).
213
214 It is true that \(G=A \).
215
216 It is false that \(z \in A \).
217
218 It is true that \(10 \in A \).
219
220 \(S = \{10, 100, 200, a, b, x, y, z\}\) % printing set S
221
222 \(H = C \cap S = \{10, a, b\}\) % printing set H
223
224 \(I = D \cup S = \{10, 100, 200, a, b, d, x, y, z\}\) % printing set I
225 \end{framed}
226
227
228 The luaset package can be modified or extended by adding custom Lua programs. Advanced users acquainted with Lua can do so.
229
230 \end{document}