Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there an "easy" way to cross the row in a matrix with a line? I am trying to demonstrate to my students how to type in LaTeX their homework assignment on Boolean function. The below table is used during the construction of normal conjunctive and disjunctive form of a Boolean function. This is a "hand" made example.

example table how it should look like

share|improve this question
    
I understand the question, but could you clarify the motivation? It seems to have become garbled... –  qubyte Jan 29 '12 at 5:50
    
@Mark In order to construct normal form for Boolean function you cross the rows with output zero and then use rows with output 1 to construct the function. For example in first row which is not crossed you have 0 under p, 0 under q and 1 under r so the form for that row is \lnot p \wedge \lnot q \wedge r. Then you want to \vee that expression with expressions for two other raws which have output 1. I just want to use TeX to cross o output raws in the same fashion I did it by hand. –  Predrag Punosevac Jan 29 '12 at 6:14
2  
I think you misunderstood me. I understand the question, but the text is actually garbled. The second sentence is the problem. –  qubyte Jan 29 '12 at 7:46
    
@Mark I wonder what was in my head when I typed that nonsense. Thank you so much for pointing the mistake!!! You should have immediately edited question yourself. –  Predrag Punosevac Jan 29 '12 at 15:11
1  
It's possible to do the full monty here and implement the entire matrix in TikZ, thus giving full access to all the entries as nodes. See tex.stackexchange.com/q/26866/86 for details. –  Andrew Stacey Jan 29 '12 at 17:26
add comment

1 Answer

up vote 9 down vote accepted

You can use tikz for this. Probably not the finest answer possible, but works for me:

\documentclass{article}
\usepackage{tikz}
\newcommand{\pmark}[1]{\begin{tikzpicture}[overlay,remember picture]\node(#1)at (-1em,.7ex){};\end{tikzpicture}}
\newcommand{\smark}[1]{\begin{tikzpicture}[overlay,remember picture]\draw(#1)--(0,.7ex);\end{tikzpicture}}
\begin{document}
$$\begin{array}{cccc|c}
a&b&bc&d&f\\\hline
0\pmark{a}&0&1&1&1\smark{a}\\
0&0&0&1&0\\
0&0&1&1&1\\
\end{array}$$
$f=\overline{a}\wedge\overline{b}\wedge c\wedge+\dots$
\end{document}
share|improve this answer
    
Yeap, it sure does! Actually you did even better. Your code provides means of controlling the length and the position of the line so that one can cross arbitrary number of entries in the line. I am guessing it could be even modified for crossing columns (I have no idea why that would be useful). –  Predrag Punosevac Jan 29 '12 at 15:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.