Make an empty or filled truth table in Typst
truth-table-empty(info: array[math_block], data: array[str]): table
# Create an empty (or filled with "data") truth table.
truth-table(..info: array[math_block]): table
# Create a filled truth table.
karnaugh-empty(info: array[math_block], data: array[str]): table
# Create an empty karnaugh table.
NAND: Equivalent to sym.arrow.t
NOR: Equivalent to sym.arrow.b
sc
Theses functions have a new named argument, called sc for symbol-convention.
You can add you own function to customise the render of the 0 and the 1. See examples.
Syntax:
#let sc(symb) = {
if (symb) {
"an one"
} else {
"a zero"
}
}
reverse
Reverse your table, see issue #3
order
Change the order of your symbol.
You can use any combination of theses values: “alphabetical”, “reverse”
- “alphabetical”: sort your symbols based on the alphabetical order.
- “reverse”: sort by changing the order of the actual list into a reverse one
Simple
#import "@preview/truthfy:0.6.0": truth-table, truth-table-empty
#truth-table($A and B$, $B or A$, $A => B$, $(A => B) <=> A$, $ A xor B$)
#truth-table($p => q$, $not p => (q => p)$, $p or q$, $not p or q$)
#import "@preview/truthfy:0.6.0": truth-table, truth-table-empty
#truth-table(sc: (a) => {if (a) {"a"} else {"b"}}, $a and b$)
#truth-table-empty(sc: (a) => {if (a) {"x"} else {"$"}}, ($a and b$,), (false, [], true))
See example.pdf and example.typ to have more examples.
If you have any idea to add in this package, add a new issue here!
0.1.0: Create the package.
0.2.0:
- You can now use
t,r,u,e,f,a,l,swithout any problems! - You can now add subscript to a letter
- Only
generate-tableandgenerate-emptyare now exported - Better example with more cases
- Implemented the
a ? b : coperator
0.3.0:
- Changing the name of
generate-tableandgenerate-emptytotruth-tableandtruth-table-empty - Adding support of
NANDandNORoperators. - Adding support of custom
scfunction. - Better example and README.md
0.4.0:
- Add
karnaugh-empty - Images re-added (see #2)
- Add
reverseoption (see #3)
0.5.0:
- Fix incorrect calculation (see #4)
0.6.0:
- Allow using
->in math mode (see #9) - Fix a simple bug with how math expressions are read (see #6)
- Add a new option:
order(see #8)