[Tex/LaTex] Draw a horizonal line over the entries of a row in an array

arrays

How to draw a horizonal line across a row (over the entries) in an array?

Best Answer

The following macro \overtabline puts a line in the middle of the previous table row assuming the row is not larger than \@arstrut (\strut for tables that also include the setting of \arraystretch).

\documentclass{article}

\renewcommand*{\arraystretch}{1.5}

\makeatletter
\newcommand*{\overtabline}{%
  \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
  }%
}
\begin{document}
\centering
\begin{tabular}{ll}
  abc&def\\
  \overtabline
  ghi&jkl\\
  \overtabline
\end{tabular}
\[
  \begin{array}{ll}
  abc&def\\
  \overtabline
  ghi&jkl\\
  \overtabline
  \end{array}
\]
\end{document}

Result

Related Question