summaryrefslogtreecommitdiff
path: root/macros/luatex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-08-16 03:00:51 +0000
committerNorbert Preining <norbert@preining.info>2023-08-16 03:00:51 +0000
commitd10719e48fc5cd329e6333041ef31d868fafbdcc (patch)
tree8f1b97fae0646e68f502c0794120636e3f5170a6 /macros/luatex
parent3593305133bcfb167225af1b35c299bde1456579 (diff)
CTAN sync 202308160300
Diffstat (limited to 'macros/luatex')
-rw-r--r--macros/luatex/latex/luatruthtable/README.txt5
-rw-r--r--macros/luatex/latex/luatruthtable/luatruthtable.bib5
-rw-r--r--macros/luatex/latex/luatruthtable/luatruthtable.pdfbin119179 -> 116768 bytes
-rw-r--r--macros/luatex/latex/luatruthtable/luatruthtable.sty20
-rw-r--r--macros/luatex/latex/luatruthtable/luatruthtable.tex228
5 files changed, 101 insertions, 157 deletions
diff --git a/macros/luatex/latex/luatruthtable/README.txt b/macros/luatex/latex/luatruthtable/README.txt
index 60217b2ce6..3e6ca97d21 100644
--- a/macros/luatex/latex/luatruthtable/README.txt
+++ b/macros/luatex/latex/luatruthtable/README.txt
@@ -1,3 +1,8 @@
+# The luatruthtable package
+# version 1.2
+# Authors: Chetan Shirore and Ajit Kumar
+# Email: mathsbeauty@gmail.com
+
# Introduction
The luatruthtable package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine. The time required for operations is no 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. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs.
diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.bib b/macros/luatex/latex/luatruthtable/luatruthtable.bib
index 81ee09ad4d..c091f4d379 100644
--- a/macros/luatex/latex/luatruthtable/luatruthtable.bib
+++ b/macros/luatex/latex/luatruthtable/luatruthtable.bib
@@ -1,13 +1,9 @@
-
-
-
@online{online.latextruthtable,
title = {Macro for automating truth tables in LaTeX},
url = {https://tex.stackexchange.com/questions/505994},
note = {visited on 2022-02-22}
}
-
@online{online.luacustomoperator,
title = {Lua Custom Operator},
url = {http://lua-users.org/wiki/CustomOperators},
@@ -17,4 +13,3 @@
-
diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.pdf b/macros/luatex/latex/luatruthtable/luatruthtable.pdf
index 3e8a60bf51..bdc5afdfdc 100644
--- a/macros/luatex/latex/luatruthtable/luatruthtable.pdf
+++ b/macros/luatex/latex/luatruthtable/luatruthtable.pdf
Binary files differ
diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.sty b/macros/luatex/latex/luatruthtable/luatruthtable.sty
index 7f57bbe254..c839b98700 100644
--- a/macros/luatex/latex/luatruthtable/luatruthtable.sty
+++ b/macros/luatex/latex/luatruthtable/luatruthtable.sty
@@ -1,9 +1,9 @@
-% luaset package
-% version 1.1
+% The luatruthtable package
+% Authors: Chetan Shirore and Ajit Kumar
+% Version 1.2, Date=15-Aug-2023
% Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
-%Authors: Chetan Shirore and Dr. Ajit Kumar
-\ProvidesPackage{luatruthtable}[1.1]
+\ProvidesPackage{luatruthtable}[1.2]
\RequirePackage{xkeyval}
\RequirePackage{amsmath}
\RequirePackage{luacode}
@@ -263,6 +263,8 @@ local res=""
local sep=" & "
trtext = trtext or "$T$"
fltext = fltext or "$F$"
+local str0 = string.gsub(str0, "%s+", "")
+local str = string.gsub(str, "%s+", "")
for variables in string.gmatch(str0, '([^,]+)') do
vars[countvars] = variables
countvars = countvars + 1
@@ -276,16 +278,14 @@ end
local n =#vars
for i =1,2^n do
itr = toBinary(i,n)
-
for j=1, #itr do
names[vars[j]] = itr[j]
end
-
for k = 1, #expr do
res= res ..sep.. load("return " .. expr[k],nil,"t",names)()
end
if i~=2^n then
-eval = eval .. table.concat(toBinary(i,n)," & ") .. res .."\\\\"
+eval = table.concat(toBinary(i,n)," & ") .. res .."\\\\" ..eval
else
eval = eval .. table.concat(toBinary(i,n)," & ") .. res
end
@@ -305,14 +305,14 @@ end
\end{luacode*}
% ========= KEY DEFINITIONS =========
-\define@key{luatruthtable}{trtext}{\def\luatrtbl@trtext{#1}}
-\define@key{luatruthtable}{fltext}{\def\luatrtbl@fltext{#1}}
+\define@key{luatruthtable}{trtext}{\def\luatrtbl@trtext{#1}}%
+\define@key{luatruthtable}{fltext}{\def\luatrtbl@fltext{#1}}%
% ========= KEY DEFAULTS =========
\setkeys{luatruthtable}{trtext=$T$,fltext=$F$}%
% ========= Defining Command =========
\newcommand{\luaTruthTable}[3][]{%
- \setkeys{luatruthtable}{#1}
+ \setkeys{luatruthtable}{#1}%
\directlua{tex.sprint(truthTable(\luastringN{#2},\luastringN{#3},'\luatrtbl@trtext','\luatrtbl@fltext'))}} %
\endinput
diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.tex b/macros/luatex/latex/luatruthtable/luatruthtable.tex
index f50267f6f8..851814bbf9 100644
--- a/macros/luatex/latex/luatruthtable/luatruthtable.tex
+++ b/macros/luatex/latex/luatruthtable/luatruthtable.tex
@@ -1,7 +1,8 @@
\documentclass{article}
-\usepackage{listings,color,parskip,booktabs,longtable,array,
+\usepackage{listings,color,booktabs,longtable,array,
hyperref,multirow,multicol,luatruthtable, enumitem}
\usepackage[top=1.1in, bottom=1.1in, left=1in, right=1in]{geometry}
+\renewcommand{\arraystretch}{1.2}
\hypersetup{colorlinks,urlcolor=blue}
\lstset{frame=none,
language=[LaTeX]{TeX},
@@ -20,34 +21,35 @@ hyperref,multirow,multicol,luatruthtable, enumitem}
\usepackage[backend=bibtex]{biblatex}
\addbibresource{luatruthtable}
\begin{document}
-\title{luatruthtable Package}
-\author{Chetan Shirore and Dr. Ajit Kumar}
+\title{The luatruthtable Package}
+\author{Chetan Shirore\thanks{Email id: mathsbeauty@gmail.com} \space and Ajit Kumar}
\maketitle
-\section{luatruthtable Package}
-The \emph{luatruthtable} package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine. The time required for operations is no 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. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs.
+\section{The luatruthtable Package}
+The \verb|luatruthtable| package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine. The time required for operations is no 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. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs.
-The progamming capabilities of Lua are effectively used in the development of pacakage. The other approaches of generating Truth Table in LaTeX get weired \cite{online.latextruthtable} and probably without using Lua it can't be done in an easier way in LaTeX. The \emph{xkeyval} package is used in its development apart from the \emph{luacode*} package.
+The programming capabilities of Lua are effectively used in the development of pacakage. The other approaches of generating Truth Table in LaTeX get weired \cite{online.latextruthtable} and probably without using Lua it can't be done in an easier way in LaTeX. The \emph{xkeyval} package is used in its development apart from the \emph{luacode*} package.
-\section{License} The \emph{luatruthtable} 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}.
+\section{License} The \verb|luatruthtable| 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 certified open source software available. Its license is simple and liberal which is compatible with GPL.
\section{Installation and Inclusion}
-The installation of \emph{luatruthtable} package is similar to plain latex package where \texttt{.sty} file is in \LaTeX directory of texmf tree. The package can be used by including the command \texttt{\textbackslash usepackage\{luatruthtable\}} in the preamble of latex document. The tex file is to be compiled using the LuaLaTeX engine.
+The installation of \verb|luatruthtable| package is similar to plain latex package where \texttt{.sty} file is in LaTeX directory of texmf tree. The package can be used by including the command \verb|\luatruthtable| in the preamble of latex document. The tex file is to be compiled using the LuaLaTeX engine.
\section{Core Ideas used in the development of the package} The function \verb|toBinary(x,y)| is used to produce sequence of \emph{True} and \emph{False} values of boolean variables. This function converts the decimal number \verb|x| to a binary number by adding \verb|y| number of leading zeroes. The result of this is stored in a table in Lua. Here \verb|y| corresponds to number of boolean variables. As \(2^y\) permutations of boolean variables are to be produced, the function \verb|toBinary(x,y)| runs inside a loop where \verb|x| takes values from \(1\) to \(y\). The splitting of variables and expressions is done using string methods available in Lua. The nested \emph{metamethods} in Lua are used to define several logical operators. The \emph{load} function in Lua is used to evaluate logical expressions.
-\section{Command luaTruthTable in luatruthtable package}
+\section{The luaTruthTable command}
The \verb|\luaTruthTable| command is the main command in the \emph{luatruthtable} package which generates truth tables. It has the following syntax.
-\begin{lstlisting}
-\luaTruthTable[trtext,fltext]{list of boolean / logical variables}{list of expressions}
+\begin{lstlisting}[caption={[]}]
+\luaTruthTable[trtext,fltext]{list of boolean/logical variables}
+{list of expressions}
\end{lstlisting}
The command has two mandatory arguments. \\
-i) \verb|list of boolean / logical variables| : The list of boolean or logical variables should be separated by comma. \\
-ii) \verb|list of expressions| : The list of logical expressions that are to be evaluated should be separated by comma. \\
+i) \verb|list of boolean / logical variables| : The list of boolean or logical variables should be separated by a comma. \\
+ii) \verb|list of expressions| : The list of logical expressions that are to be evaluated should be separated by a comma. \\
The command has two optional arguments. \\
i) \verb|trtext| : The \verb|trtext| is the display value for the boolean value \emph{True}. It has the default value \verb|$T$| in the package. It can be any string or number. Assigning value \(0\) should be avoided to \verb|trtext| variable. \\
ii) \verb|fltext| : The \verb|fltext| is the display value for the boolean value \emph{False}. It has the default value \verb|$F$| in the package. It can be any string or number. Assigning value \(1\) should be avoided to \verb|fltext| variable.
-The \verb|\luaTruthTable| command should be used within in the environment \verb|\begin{tabular} ... \end{tabular}| or any other environment in LaTeX for Tables. The sequence of column heads should be same as sequence of \verb|list of boolean / logical variables| and \verb|list of expressions|. Without these correct inputs, the command \verb|\luaTruthTable| can't produce the expected output.
+The \verb|\luaTruthTable| command should be used within in the environment \verb|\begin{tabular} ... \end{tabular}| or any other environment in LaTeX for tables. The sequence of column heads should be same as sequence of \verb|list of boolean/logical variables| and \verb|list of expressions|. Without these correct inputs, the command \verb|\luaTruthTable| can not produce the desired output.
-\section{Operations in luatruthtable package}
+\section{Operations in the luatruthtable package}
\begin{enumerate}[label=\alph*)]
\item \emph{not}: The value of \emph{ not p} is False when \(p\) is True and it is True when \(p\) is False.
\begin{center}
@@ -157,200 +159,142 @@ The command \verb|*lognor*| is used in the package to generate truth table for
The command \verb|*logxnor*| is used in the package to generate truth table for \emph{XNOR} operation.
\end{enumerate}
-The following table summarises logical operators in the package.
+Table \ref{tbl:truthop} describes operators in the \verb|luatruthtable| package.
\begin{center}
-\begin{longtable}{llm{8cm}}
+\begin{longtable}{llm{9cm}}
\toprule
\multicolumn{1}{c}{\textcolor{blue}{Operator}} & \multicolumn{1}{l}{\textcolor{blue}{Syntax}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\
\toprule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
lognot*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
lognot*p
-\end{lstlisting} & Negates the boolean variable \(p\)\\
+\end{lstlisting} & Negates the boolean variable \(p\).\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*logand*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*logand*q
-\end{lstlisting} & Gives the truth of the expression \emph{p and q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{p and q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*logor*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*logor*q
-\end{lstlisting} & Gives the truth of the expression \emph{p or q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{p or q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*imp*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*imp*q
-\end{lstlisting} & Gives the truth of the expression \emph{if p then q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{if p then q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*iff*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*iff*q
-\end{lstlisting} & Gives the truth of the expression \emph{p if and only if q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{p if and only if q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*lognand*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*lognand*q
-\end{lstlisting} & Gives the truth of the expression \emph{ p NAND q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{ p NAND q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*logxor*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*logxor*q
-\end{lstlisting} & Gives the truth of the expression \emph{ p XOR q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{ p XOR q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*lognor*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*lognor*q
-\end{lstlisting} & Gives the truth of the expression \emph{ p NOR q} for boolean variables \(p\) and \(q\).\\
+\end{lstlisting} & Gives the truth value of the expression \emph{ p NOR q}.\\
\midrule
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
*logxnor*
\end{lstlisting} &
-\begin{lstlisting}
+\begin{lstlisting}[caption={[]}]
p*logxnor*q
-\end{lstlisting} & Gives the truth of the expression \emph{ p XNOR q} for boolean variables \(p\) and \(q\).\\
-
-\bottomrule
+\end{lstlisting} & Gives the truth value of the expression \emph{ p XNOR q}.\\
+\bottomrule \\
+\caption{Operators in the luatruthtable package}
+\label{tbl:truthop}
\end{longtable}
\end{center}
-\section{Examples and Usage} The \emph{luatruthtable} package can accept finite number of variables. It supports finite number of variables that one would practically need. Few examples of usage are given here.
-\begin{lstlisting}
+\section{Illustrations of commands in the luatruthtable package}\label{illtruth}
+
+The \emph{luatruthtable} package can accept a finite number of variables. It supports a finite number of variables that one would need.
+
+\begin{lstlisting}[label={code:illluatruth}, caption={LaTeX document with luatruthtable package}]
\begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
\hline
\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
& \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
\hline
-\luaTruthTable{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q,
-p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
+\luaTruthTable{p,q}{lognot*p, p*logand*q, p*logor*q, p*imp*q, p*iff*q,
+p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
\hline
\end{tabular}
-\end{lstlisting}
-With the packages \emph{luatruthtable},the above code outputs to
-\ \\ \ \\
+\end{lstlisting}
+
+The LaTeX code (Listing \ref{code:illluatruth}) generates the output shown in Table \ref{tbl:luatruthtbl}.
+\begin{table}[h]
+\centering
\begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
\hline
\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
& \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
\hline
-\luaTruthTable{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q,
-p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
-\hline
-\end{tabular}
-\ \\ \\
-The following is the code generated by the command \verb|\luaTruthTable| in above code.
- \begin{lstlisting}
-$F$ & $T$ & $T$ & $F$ & $T$ & $T$ & $F$ & $T$ & $T$ & $F$ & $F$\\
-$T$ & $F$ & $F$ & $F$ & $T$ & $F$ & $F$ & $T$ & $T$ & $F$ & $F$\\
-$T$ & $T$ & $F$ & $T$ & $T$ & $T$ & $T$ & $F$ & $F$ & $F$ & $T$\\
-$F$ & $F$ & $T$ & $F$ & $F$ & $T$ & $T$ & $T$ & $F$ & $T$ & $T$
- \end{lstlisting}
- The following example illustrates the use use of \emph{trtext} and \emph{fltext}. Here \(0\) is assigned to \emph{trtext} and \(1\) is assigned to \emph{fltext}.
- \begin{lstlisting}
- \begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
-\hline
-\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
- & \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
-\hline
-\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q,
-p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
-\hline
-\end{tabular}
- \end{lstlisting}
-
- With the packages \emph{luatruthtable},the above code outputs to
-\ \\ \ \\
- \begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|}
-\hline
-\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\)
- & \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\
-\hline
-\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q,
-p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
-\hline
-\end{tabular}
-\ \\ \\
-The following is the code generated by the command \verb|\luaTruthTable| in above code.
-\begin{lstlisting}
-$0$ & $1$ & $1$ & $0$ & $1$ & $1$ & $0$ & $1$ & $1$ & $0$ & $0$\\
-$1$ & $0$ & $0$ & $0$ & $1$ & $0$ & $0$ & $1$ & $1$ & $0$ & $0$\\
-$1$ & $1$ & $0$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $1$\\
-$0$ & $0$ & $1$ & $0$ & $0$ & $1$ & $1$ & $1$ & $0$ & $1$ & $1$
-\end{lstlisting}
-The following example involves three variables.
-\begin{lstlisting}
-\begin{tabular}{|ccc|c|}
-\hline
-\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\
-\hline
-\luaTruthTable{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\luaTruthTable{p,q}{lognot*p, p*logand*q, p*logor*q, p*imp*q, p*iff*q,
+p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\
\hline
\end{tabular}
-\end{lstlisting}
- With the packages \emph{luatruthtable},the above code outputs to
-\ \\ \ \\
-\begin{tabular}{|ccc|c|}
+ \caption{Example 1}
+ \label{tbl:luatruthtbl}
+ \end{table}
+
+
+\begin{lstlisting}[label={code:illluatruth2}, caption={LaTeX document with luatruthtable package}]
+\begin{tabular}{|cccc|c|}
\hline
-\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\
+\(p\) & \(q\) & \( r\) & \(s\) & \(((p\land q) \rightarrow \neg r) \land s \) \\
\hline
-\luaTruthTable{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\luaTruthTable{p,q,r,s}{((p*logand*q)*imp*(lognot*r))*logand*s } \\
\hline
\end{tabular}
-\ \\ \\
-Here \emph{lognot*r} should be enclosed in parenthesis in order to produce correct results in generated truth table.
-\ \\
-The following is the code generated by the command \verb|\luaTruthTable| in above code.
-\begin{lstlisting}
-$F$ & $F$ & $T$ & $T$\\
-$F$ & $T$ & $F$ & $T$\\
-$F$ & $T$ & $T$ & $T$\\
-$T$ & $F$ & $F$ & $T$\\
-$T$ & $F$ & $T$ & $T$\\
-$T$ & $T$ & $F$ & $T$\\
-$T$ & $T$ & $T$ & $F$\\
-$F$ & $F$ & $F$ & $T$
-\end{lstlisting}
-With the use of optional arguments \verb|[trtext=True, fltext=False]| in the previous example, one gets the following output.
-\ \\ \ \\ \ \\
-\begin{tabular}{|ccc|c|}
+\end{lstlisting}
+
+The LaTeX code (Listing \ref{code:illluatruth2}) generates the output shown in Table \ref{tbl:luatruthtbl2}.
+\begin{table}[h]
+\centering
+\begin{tabular}{|cccc|c|}
\hline
-\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\
+\(p\) & \(q\) & \( r\) & \(s\) & \(((p\land q) \rightarrow \neg r) \land s \) \\
\hline
-\luaTruthTable[trtext=True, fltext=False]{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
+\luaTruthTable{p,q,r,s}{((p*logand*q)*imp*(lognot*r))*logand*s } \\
\hline
\end{tabular}
-\ \\ \\
+ \caption{Example 2}
+ \label{tbl:luatruthtbl2}
+ \end{table}
+
+
-It is possible to input \emph{trtext} and \emph{trfalse} in mathematics environment. So with the use of optional arguments \verb|[trtext=$True$, fltext=$False$]| in the previous example, one gets the following output.
-\ \\ \ \\ \ \\
-\begin{tabular}{|ccc|c|}
-\hline
-\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\
-\hline
-\luaTruthTable[trtext=$True$, fltext=$False$]{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\
-\hline
-\end{tabular}
-\ \\ \ \\ \ \\
-Since \emph{luacode*} package is used, the backslash is to be escaped while assigning values to \emph{trtext} and \emph{trfalse}. For example \verb|[trtext=\\(True\\), fltext=\\(False\\)]|
-\section{Known Issues,Limitations and Scope of the package} The associativity and precedence of operator is not yet supported. The package can give appropriate results only when parentheses are used for each of the operation. It gives eraneous result when parentheses are not used. This point is of utmost importance in using the package. These issues are there is no native way of defining custom operations in Lua \cite{online.luacustomoperator}. However some metamethods can be nested in a way to glimpse the operators. All operators defined in this package are instances of such nestings. The question may be raised that is there better way of accomplishing this in Lua. The answer to the point is that there are alternative ways of doing this. They may be better in some or other sense. For example, instead of defining \emph{*logand*} operator and using it in the fashion \emph{p*logand*q}, one could define function \emph{logand} that takes two arguments and use it in a way \emph{logand(p,q)}. But when it comes to embedding it in LaTeX, again one has to use more and more nested parentheses as number of statements and operations increase. This is the exact reason why such approach is not used in the development of package. Instead of using \emph{implies(logand(p,logor(q,r)),s)} it sounds more natural to use \emph{(p *logand* (q*logor*r) )*implies* s}.
+\section{Known Issues, Limitations and Scope of the package} The associativity and precedence of operator is not yet supported. The package can give appropriate results only when parentheses are used for each of the operation. It gives eraneous result when parentheses are not used. This point is of utmost importance in using the package. These issues are there is no native way of defining custom operations in Lua \cite{online.luacustomoperator}. However some metamethods can be nested in a way to glimpse the operators. All operators defined in this package are instances of such nestings. The question may be raised that is there better way of accomplishing this in Lua. The answer to the point is that there are alternative ways of doing this. They may be better in some or other sense. For example, instead of defining \emph{*logand*} operator and using it in the fashion \emph{p*logand*q}, one could define function \emph{logand} that takes two arguments and use it in a way \emph{logand(p,q)}. But when it comes to embedding it in LaTeX, again one has to use more and more nested parentheses as number of statements and operations increase. This is the exact reason why such approach is not used in the development of package. Instead of using \emph{implies(logand(p,logor(q,r)),s)} it sounds more natural to use \emph{(p *logand* (q*logor*r) )*implies* s}.
Apart from these issues, there is no error handling mechanism used in the package. It relies on the error handling of Lua and TeX itself. The package currently supports 9 operations viz. \emph{not,and,nand,or, xor, implies, iff, nor, xnor}. The error handling and extending number of operations may be considered in future versions of the package.