Wie kann ich eine Zeile oder Spalte in einer Matrix durchstreichen?

Wie kann ich eine Zeile oder Spalte in einer Matrix durchstreichen?

Ich möchte eine Zeile und eine Spalte in meiner Matrix kreuzen, weiß es aber noch nicht.

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{ulem}
\usepackage{kbordermatrix}% http://www.hss.caltech.edu/~kcb/TeX/kbordermatrix.sty
\usepackage{soul}
\begin{document}

    \renewcommand{\kbldelim}{(}% Left delimiter
    \renewcommand{\kbrdelim}{)}% Right delimiter
    \[
    \text{matriz} = \kbordermatrix{
        & t1 & t2 & t3 & t4 & t5 \\
        a1 & 1 & 1 & 1 & 1 & 0 \\
        a2 & 0 & 1 & 14 & 99 & 0 \\
        a3 & 0 & 0 & 1 & 0 & 0 \\
        a4 & 0 & 0 & 0 & 1 & 0 \\
        a5 & 30 & 155 & 0 & 0 & 0
    }
    \]

\end{document}

rix

Antwort1

Sie können verwenden nicematrix, wodurch unter jeder Zelle der Matrix ein PGF/Tikz-Knoten erstellt wird. Anschließend können Sie mit Tikz die gewünschten Linien zeichnen.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}

\begin{document}
\[
    \text{matriz} = 
\begin{pNiceMatrix}[first-row,first-col]
 & t_1 & t_2 & t_3 & t_4 & t_5 \\
 a_1 & 1 & 1 & 1 & 1 & 0 \\
 a_2 & 0 & 1 & 14 & 99 & 0 \\
 a_3 & 0 & 0 & 1 & 0 & 0 \\
 a_4 & 0 & 0 & 0 & 1 & 0 \\
 a_5 & 30 & 155 & 0 & 0 & 0
\CodeAfter
\begin{tikzpicture}
 \draw [thick,red] (3-1.west) -- (3-5.east) ; 
 \draw [thick,blue] (4-0.west|-4-5.east) -- (4-5.east) ; 
\end{tikzpicture}
\end{pNiceMatrix}
\]

\end{document}

Ergebnis des obigen Codes

verwandte Informationen