Changes

Jump to navigation Jump to search
457 bytes added ,  01:16, 9 July 2021
no edit summary
This is a ConTeXt user module that draws Karnaugh maps containing data (ones, ceros, or anything) and their groupings, with easy to use syntax. It supports larger than four variable maps; and formulas, or any text, can be added.
The download page is [https://modules.contextgarden.net/cgi-bin/module.cgi/ruid=3120012435/action=view/id=111 here] The PDF documentation (with the actual maps) is [https://githubraw.githubusercontent.com/VicSanRoPe/context-karnaugh/blob/master/doc/context/third/karnaugh/karnaugh-docs.pdf here]
= Options =
nx = NUMBER
name = TEXT
labelstyle = edge cornerbars
groupstype = pass stop
indices = yes no on off
spacing = small big normal NUMBER
indicesstart = NUMBER</pre>
 * The options <code>ylabels</code> and <code>xlabels</code> are the input variables used for the map, they are written as a list, and math mode is usually used for each individual element. <code>xlabels</code> refers to the variables at the top of the map, and the last element is the least significant variable (for indices and minterms). <code>ylabels</code> are at the left, its first element is the most significant variable. If these labels are not specified, then the labels will be I<sub>05</sub> , I<sub>14</sub> , ... , I<sub>20</sub>, and so on. 
* The options <code>ny</code> and <code>nx</code> are the map’s size in number of cells, they are calculated automatically when labels are specified, and if no size or labels are specified but there is data, the size of the map is guessed with the newline characters.
 
* The <code>name</code> option is some text that is added on top or on the top-left corner of the map, the name of the function could be placed there.
 * The <code>labelstyle</code> option specifies whether the input variables are placed in a corner of the map (value: <code>corner</code>) or at the edges (value: <code>edge</code>), or if they are placed on top of bars which represent when the variable's value is 1 (value: <code>bars</code>). By default, the <code>corner </code> style is used for small maps and the <code>edge </code> style is used for 5 variable maps or larger. 
* The <code>groupstyle</code> option changes how the group’s lines are drawn, if its value is <code>pass</code> (the default), the lines continue for a bit outside of the map. If it is <code>stop</code>, they will not, which might be preferred when making a combination of maps using the overlay method, to mark that some adjacent groups are not connected, but the effect is minimal.
 
* If the <code>indices</code> option is set to yes or on, it will draw a small number on every cell with the value of the input variables in decimal. If groups are also being drawn, the map’s spacing will be enlarged to accommodate both things and the data.
 
* The <code>spacing</code> option simply increases or decreases the whitespace around every cell’s data. Please note that the document’s font size affects the map’s size, such that is looks the same, just smaller or bigger, always with the same font as the main text. To make the maps have a constant size, surround them with <code>\scale</code> spacing can be a number too, adjust both of these to get the proportions you want.
After drawing a Karnaugh map, it is useful to know which term of the produced formula represents each group. These can be drawn as text with arrows coming from the desired group.
<pre>\karnaughnote {[...}{][...}]{...} CHARACTER CONTENT tr Tr tl Tl br Br bl Bl lb lt rb rt t b l r b CONTENT</pre>The base of the arrow is specified in the <code>karnaughgroups</code> environment as an asterisk after the group it represents, and the remaining data is specified using the <code>karnaughnote</code> command. The first argument is the character assigned to the group, the second is the text to be added to the map, and the third is one of the specified directions the arrow may point to, and the third is the text to be added to the map.
The first letter of the direction is where it will mainly point towards, with <code>t</code> meaning top, <code>b</code> meaning bottom, <code>l</code> meaning left, and <code>r</code> meaning right; if it is uppercase it will be further separated from the map (for two rows of text, for example). The second letter (if present) will be a slight offset to the desired side, mainly to make the arrow not overlap with the grey code to the top and left. The arrows look better when they come out of a group’s corner.
 
If the <code>labelstyle</code> option is <code>bars</code> and there are notes, the bars will be spaced further apart from the map to make space for short text.
<texcode>
A*, , , A,
\stopkarnaughgroups
\karnaughnote{[A}][b]{A's note}{b} \karnaughnote{[B}][Tr]{B's note}{Tr} \karnaughnote{[C}][rb]{C's note}{rb}
\stopkarnaugh
</texcode>
5

edits

Navigation menu