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.

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

share|improve this question
1  
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
add comment

2 Answers 2

This can also be done using \tikzmark:

enter image description here

Note:

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}
share|improve this answer
add comment

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

share|improve this answer
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.