1

Related to Make first row of table all bold, however the solution seems not to be transferable to striking text through (see Strikethrough command that affects all following text, like \bfseries).

So far my solution works by overlaying the respective line with

\renewcommand{\sttableline}{\rlap{\rule[3pt]{1\paperwidth}{.4pt}}}

through a command in the spirit of my first referenced Q&A above. This is however very unflexible and needs manual adjustment depending on how the respective table is scaled/placed on the page.

Edit: Idealy the solution I'm looking for would work withou any modification in the last columns and only need modification of the table header and entries in the first columns.

1
  • The two solution that were already provided answer my original question. However what I am looking for is slightly different. So I've added that I'd prefer a solution that works without modifying adding (something inside) an additional last column. The reason is that the table content is generated by another software.
    – sheß
    Sep 4 '15 at 12:07
3

While someone else provides a better answer, you can always use a tikzmark

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

\begin{document}
\begin{tabular}{lcr}
a & a & a \\
\tikzmark{start}b & b & b\tikzmark{end} \\
c & c & c \\
\end{tabular}

\tikz[remember picture] \draw[overlay] ([yshift=.35em]pic cs:start) -- ([yshift=.35em]pic cs:end);
\end{document}

enter image description here

1

Something like this might be workable. There is a slight difference in approach from the cited answer of the OP. That is, a phantom column must be added at the end of the row (the added space of it is compensated for with a @{\hspace{-\tabcolsep}} as is shown in my MWE with an \fbox around the tabular).

An alternative to the phantom column is to add \relax prior to \\ at the end of each tab row.

\documentclass{article}
\usepackage{array}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\relax\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces%
}
\def\mystyle#1\relax{\setbox0=\hbox{#1}\rule[2pt]{\wd0}{1pt}\kern-\wd0#1}
\begin{document}
\fbox{\begin{tabular}{$l^c^r^c@{\hspace{-\tabcolsep}}}
\rowstyle{\mystyle}
This is an entry & another entry & a third entry&\\
b & b & b &\\
\rowstyle{\mystyle}
data & other data & last data &\\
\end{tabular}}
\end{document}

enter image description here

An alternate way to achieve the same thing, requiring a little less typing in the tabular itself, is to define the ! column type

\documentclass{article}
\usepackage{array}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\relax\currentrowstyle}}
\newcolumntype{!}{>{\relax\hspace*{-2\tabcolsep}}c}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces%
}
\def\mystyle#1\relax{\setbox0=\hbox{#1}\rule[2pt]{\wd0}{1pt}\kern-\wd0#1}
\begin{document}
\fbox{\begin{tabular}{$l^c^r!}
\rowstyle{\mystyle}
This is an entry & another entry & a third entry&\\
b & b & b &\\
\rowstyle{\mystyle}
data & other data & last data &\\
\end{tabular}}
\end{document}
1

A solution with pst-node. I used the \psDefBoxNodes, which puts its contents in a box and defines a series of nodes in that box (12 nodes in all), then I connected a node from the first element in the row to a node from the last element in the row:

\documentclass[x11names]{article}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{postscript}
  \begin{tabular}{lcr}
    a & a & a \\
    \psDefBoxNodes{B1}{b} & b & \psDefBoxNodes{B2}{b} \\
    c & c & c \\
  \end{tabular}
  \ncline[nodesep=-2pt, offset=-0.3ex, linewidth=0.4pt, linecolor=IndianRed3]{B1: Cl}{B2: Cr}
\end{postscript}

\end{document}

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.