\documentclass{article} \usepackage{listings,color,booktabs,longtable,array,hyperref,multicol,framed} \usepackage[ left=1in, right=1in]{geometry} \hypersetup{colorlinks,urlcolor=blue} \lstset{frame=none, language=[LaTeX]{TeX}, aboveskip=3mm, belowskip=3mm, showstringspaces=false, columns=flexible, basicstyle={\ttfamily}, numbers=none, numberstyle=\tiny\color{gray}, stringstyle=\color{mauve}, breaklines=true, breakatwhitespace=true, tabsize=1 } \usepackage[backend=bibtex]{biblatex} \begin{document} \title{The luaset Package in LaTeX} \author{Chetan Shirore\thanks{Email id: mathsbeauty@gmail.com} \space and Ajit Kumar} \maketitle \section{Introduction}\label{section:introduction} 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. \section{Installation and License} 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. 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. \subsection{Defining and Displaying Sets} A set can be defined by using the \verb|\luaSetNew| command. \begin{lstlisting} \luaSetNew{name}{set} \end{lstlisting} The following commands define sets \( A \) and \(B \). \begin{lstlisting} \luaSetNew{A}{a,b,c,10,d,10,a,30} \luaSetNew{B}{d,e,f,10,20} \end{lstlisting} The set can be displayed or printed by using the \verb|\luaSetPrint| command. \begin{lstlisting} \luaSetPrint{name of set} \end{lstlisting} For example, the following commands \begin{lstlisting} \(A = \luaSetPrint{A}\) \\ \(B = \luaSetPrint{B}\) \end{lstlisting} output to \begin{framed} \noindent \(A = \{10, 30, a, b, c, d\}\) \\ \(B = \{10, 20, d, e, f\}\) \end{framed} The standard mathematical functions can also be used. \subsection{Commands in the luaset package} Table \ref{tbl:opluaset} summarises commands in the \verb|luaset| package. \begin{center} \begin{longtable}{llm{5cm}} \toprule \multicolumn{1}{c}{\textcolor{blue}{Function}} & \multicolumn{1}{c}{\textcolor{blue}{Command Format}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\ \toprule \begin{lstlisting} \luaSetUnion \end{lstlisting} & \begin{lstlisting} \luaSetUnion{set}{set1}{set2} \end{lstlisting} & Defines the new set as a union of set1 and set2. \\ \midrule \begin{lstlisting} \luaSetIntersection \end{lstlisting} & \begin{lstlisting} \luaSetIntersection{set}{set1}{set2} \end{lstlisting} & Defines the new set as an intersection of set1 and set2. \\ \midrule \begin{lstlisting} \luaSetDifference \end{lstlisting} & \begin{lstlisting} \luaSetDifference{set}{set1}{set2} \end{lstlisting} & Defines the new set as a difference of set1 and set2. \\ \midrule \begin{lstlisting} \luaSetCardinal \end{lstlisting} & \begin{lstlisting} \luaSetCardinal{set} \end{lstlisting} & Gives the cardinality of a set (number of elements). \\ \midrule \begin{lstlisting} \luaSetBelongsto \end{lstlisting} & \begin{lstlisting} \luaSetBelongsto{element}{set} \end{lstlisting} & Returns true if an element is in a set; otherwise, it returns false.\\ \midrule \begin{lstlisting} \luaSetSubseteq \end{lstlisting} & \begin{lstlisting} \luaSetSubseteq{set1}{set2} \end{lstlisting} & Returns true if set1 is a subset of set2; otherwise, it returns false. \\ \midrule \begin{lstlisting} \luaSetSubset \end{lstlisting} & \begin{lstlisting} \luaSetSubset{set1}{set2} \end{lstlisting} & Returns true if set1 is a proper subset of set2; otherwise, it returns false. \\ \midrule \begin{lstlisting} \luaSetEqual \end{lstlisting} & \begin{lstlisting} \luaSetEqual{set1}{set2} \end{lstlisting} & Returns true if set1 is equal to set2; otherwise, it returns false. \\ \bottomrule \caption{Commands in the luaset package} \label{tbl:opluaset} \end{longtable} \end{center} \subsection{Examples and Usage} The latex document (Listing: \ref{code:illluaset}) uses various commands in the \verb|luaset| package. \begin{lstlisting}[label={code:illluaset}, caption={LaTeX document with luaset package}] \documentclass{article} \usepackage{luaset,parskip} \begin{document} \luaSetNew{A}{a,b,c,\mathCos{0},d,10,a,30} \luaSetNew{B}{d,e,f,10,20} \luaSetUnion{C}{A}{B} \luaSetIntersection{D}{A}{B} \luaSetDifference{E}{A}{B} \luaSetDifference{F}{B}{A} \(A = \luaSetPrint{A}\) % printing set A \(B = \luaSetPrint{B}\) % printing set B \(C = A \cup B = \luaSetPrint{C}\) % printing set C \(D = A\cap B = \luaSetPrint{D}\) % printing set D \(E = A-B = \luaSetPrint{E}\) % printing set E \(F = B-A = \luaSetPrint{F}\) % printing set F The Cardinality of set \(A\) is \luaSetCardinal{A}. It is \luaSetSubseteq{A}{B} that \(A \subseteq B \). It is \luaSetSubseteq{A}{C} that \(A \subseteq C \). It is \luaSetSubset{A}{B} that \(A \subset B \). It is \luaSetSubset{A}{C} that \(A \subset C \). \luaSetIntersection{G}{C}{A} \(G = C \cap A = \luaSetPrint{G}\) % printing set G It is \luaSetEqual{A}{B} that \(A=B \). It is \luaSetEqual{G}{A} that \(G=A \). It is \luaSetBelongsto{z}{A} that \(z \in A \). It is \luaSetBelongsto{10}{A} that \(10 \in A \). \luaSetNew{S}{a,10,b,x,y,z,100,200} \(S = \luaSetPrint{S}\) % printing set S \luaSetIntersection{H}{C}{S} \luaSetUnion{I}{D}{S} \(H = C \cap S = \luaSetPrint{H}\) % printing set H \(I = D \cup S = \luaSetPrint{I}\) % printing set I \end{document} \end{lstlisting} The latex document (Listing: \ref{code:illluaset}) generates the following output on the compilation. \begin{framed} \(A = \{10, 30, 1.0, a, b, c, d\}\) % printing set A \(B =\{10, 20, d, e, f\}\) % printing set B \(C = A \cup B = \{10, 20, 30, 1.0, a, b, c, d, e, f\}\) % printing set C \(D = A\cap B = \{10, d\}\) % printing set D \(E = A-B = \{30, 1.0, a, b, c\}\) % printing set E \(F = B-A = \{20, e, f\}\) % printing set F The Cardinality of set \(A\) is 7. It is false that \(A \subseteq B \). It is true that \(A \subseteq C \). It is false that \(A \subset B \). It is true that \(A \subset C \). \(G = C \cap A = \{10, 30, 1.0, a, b, c, d\}\) % printing set G It is false that \(A=B \). It is true that \(G=A \). It is false that \(z \in A \). It is true that \(10 \in A \). \(S = \{10, 100, 200, a, b, x, y, z\}\) % printing set S \(H = C \cap S = \{10, a, b\}\) % printing set H \(I = D \cup S = \{10, 100, 200, a, b, d, x, y, z\}\) % printing set I \end{framed} The luaset package can be modified or extended by adding custom Lua programs. Advanced users acquainted with Lua can do so. \end{document}