1

So using the last answer from here, as I am using an array not any matrix. I am using MathTex for Libre Office Writer. FYI.

Normal Matrix:

enter image description here

\left[
\begin{array}{ccc}
3 & 3 & 1 \\
1 & 0 & -4 \\
1 & -3 & 5
\end{array}
\right]

And my Stiked Matrix:

enter image description here

\renewcommand*{\arraystretch}{1.5}

\makeatletter
\newcommand*{\rowstrike}{%
  \noalign{%
    % normal "baselineskip" in tabular is height + depth of \@arstrutbox
    \vskip-.5\dimexpr\ht\@arstrutbox+\dp\@arstrutbox\relax
    % default line thickness is 0.4pt
    \vskip-.2pt\relax
    \hrule
    \vskip-.2pt\relax
    \vskip+.5\dimexpr\ht\@arstrutbox+\dp\@arstrutbox\relax
  }%
}
\newcommand{\colstrike}{%
  @{\hspace{2\tabcolsep}}|@{\hspace{-.5\tabcolsep}}c@{}@{\hspace{1.5\tabcolsep}}
}
\left[
\begin{array}{@{}\colstrike cc}
3 & 3 & 1 \\
1 & 0 & ^-4 \\ \rowstrike
1 & ^-3 & 5
\end{array}
\right]

The problem is in my Column strike through, the alignment of the second row is messed up. I would like to modify my macro so as to have a single command to strike any column, of any size (if possible). And, to fix the alignment. Got the alignment to work by altering:

@{\hspace{2\tabcolsep}}|@{\hspace{-.5\tabcolsep}}c@{}

to:

@{\hspace{2\tabcolsep}}|@{\hspace{-.5\tabcolsep}}c@{}@{\hspace{1.5\tabcolsep}}

enter image description here

But it only works for a single number, any more and this occurs:

enter image description here

I would like it to be centred on the column.

EDIT:

I tried to use a tikz command from another question, but it does not work right:

\usepackage{tikz}

\newcommand{\tm}[2]{%
     \tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {$#2$};%
}

\newcommand{\DrawVLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.3ex, #1] (#2.north) -- (#3.south);
  \end{tikzpicture}
}

\newcommand{\DrawHLine}[3][]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[shorten <=0.2em, #1] (#2.west) -- (#3.east);
  \end{tikzpicture}
}

\left[
\begin{array}{ccc}
\tm{topA}{3} & 3 & 1 \\
\tm{leftA}{1} & 0 & \tm{rightA}{^-4} \\
\tm{bottomA}{1} & ^-3 & 5
\end{array}
\right]
\DrawHLine[black, thick, opacity=0.5]{topA}{bottomA}
\DrawVLine[black, thick, opacity=0.5]{leftA}{rightA}

Which results in:

enter image description here

  • What do you mean with this? It seems pretty centered. – TeXnician May 30 '17 at 4:22
  • It is the strikeout on the first column I want to fix, as you see in the last image the strike hits the '3' in '3123123' but not the '1's in the second and third rows. – Drew May 30 '17 at 4:24
  • I suppose you could change @{\hspace{2\tabcolsep}}|@{\hspace{-.5\tabcolsep}} to @{\hspace{4.5\tabcolsep}}|@{\hspace{-3\tabcolsep}} – Mico May 30 '17 at 5:08
  • I think the problem lies in \tabcolsep, being a specific number of characters, which would work, if I could get the largest number of characters in a certain column, and supply 1/2 that number to the \tabcolsep. Is there a way to do that? – Drew May 30 '17 at 5:13
  • The \colstrike method proposed in @Werner's answer -- which he himself called "rudimentary" -- was only every meant to work with columns that contain single letters or numerals. For more general situations, you should look into employing one of the tikz-based methods proposed in the other answers. – Mico May 30 '17 at 5:21
1

The last code does work, you misplaced the commands \DrawHLine and \DrawVLine so the lines could not be orthogonal.

\DrawVLine[black, thick, opacity=0.5]{topA}{bottomA}
\DrawHLine[black, thick, opacity=0.5]{leftA}{rightA}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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