# Draw a horizonal line over the entries of a row in an array

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

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. –  Kurt Oct 30 '12 at 17:16
–  Peter Grill Aug 13 '14 at 23:14

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}


-

This can also be done using \tikzmark:

## Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawLine}[3][]{%
\begin{tikzpicture}[overlay,remember picture]
\draw [#1] ($(#2)+(0,0.6ex)$) -- ($(#3)+(0,0.6ex)$);
\end{tikzpicture}%
}%
\begin{document}
$\begin{array}{c c c} a & b & c \\ \tikzmark{StartA}1 & 2 & 3\tikzmark{EndA} \\ \tikzmark{StartB}f & g & h\tikzmark{EndB} \end{array}$
\DrawLine[red, thick]{StartA}{EndA}
\DrawLine[blue, thick, dotted]{StartB}{EndB}
\end{document}

-