# Creating a specific (locally vertical-first) cell highlighting order in the PDF

I have a table with a bunch of split cells (or large \multirow cells, depending on how one looks at it). This is a minimal example, for the setup I need the table in:

\documentclass{memoir}
\usepackage{float}
\usepackage{arydshln}

\begin{document}

\begin{Spacing}{1}
\begin{table}[H]
\caption{Selection of popular Linux distributions}
\begin{center}
\begin{small}
\begin{tabular}{|l|l|l|}
\hline
\hline
Debian GNU/Linux & Debian & Ian Murdock \\
\hline
\specialcell{Red Hat \\ Enterprise Linux} & RHEL & \specialcell{Red Hat, \\ Inc.} \\
\cdashline{1-2}[.4pt/1pt]
\specialcell{\ \ \textit{formerly:} \\ \ \ Red Hat Linux \\ \ \ Advanced Server} & \ \ --- & {} \\
\hline
Slackware & --- & \specialcell{Patrick \\ Volkerding} \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\end{Spacing}

\end{document}


(1. Conceptually, a number of things (such as a special font for column headings) are not necessary, but it's good if the solution works for a non-trivial/non-minimal setup. 2. Please don't modify the cell contents: some things (such as the fact that the middle row cluster's cells aren't the longest ones that define the column width) are intentional.)

What's working is the layout: visually everything is as I want it. What is not yet right however is a certain highlighting order I want, for when I select text in the compiled PDF file. The current highlighting selection order for cells in the PDF file is

"Red Hat Enterprise Linux" → "RHEL" → "Red Hat, Inc." → "formerly [...]" → "---".

I however want:

"Red Hat Enterprise Linux" → "formerly [...]" → "RHEL" → "---" → "Red Hat, Inc."

I've tried many things, involving \multirow, \minipage, and tricks involving storing the column length somewhere (\newlength{\colwidthColumnnumber} \settowidth{\colwidthColumnnumber}{Debian GNU/Linux}), but there is always something that doesn't work. I get:

• the dots for the split cells are too short and don't cover the entire cell width
• extraneous empty lines in cells
• error messages involving \\/&/\cr
• missing or doubly-thick vertical bars

By the way, it seems that the correct way to apply \cdashline to a single column is to write \cdashline{1-1}, not \cdashline{1}.

Is there an easy way to keep the exact current visual appearance (cell layout and contents), with only the cell selection order different? This might involve playing around more with subtables.

Note: Normally the \specialcell-trick (see my code; it's a variation of a solution to another question by user @egreg) suffices. It's the dotted line (from package arydshln) that makes things complicated and that necessitate a more general treatment.

-

To keep a specific selection order, you have to set the contents of the entire cell at the same time, before moving on the next cell. I've done that in the following example by wrapping the cell structure inside a \smash. This allows one to set as much as you want without it affecting the rest of the tabular. The [t]op-alignment of \specialcell helps, and I've corrected any overflow with some empty lines:

\documentclass{memoir}% http://ctan.org/pkg/memoir
\usepackage{float,arydshln}% http://ctan.org/pkg/{float,arydshln}

\newcommand{\specialcell}[1]{\begin{tabular}[t]{@{}l@{}}#1\end{tabular}} % http://tex.stackexchange.com/q/2441/5764

\begin{document}

\begin{Spacing}{1}
\begin{table}[H]
\caption{Selection of popular Linux distributions}
\centering\small
\begin{tabular}{|l|l|l|}
\hline
\hline
Debian GNU/Linux & Debian & Ian Murdock \\
\hline
\smash{\specialcell{RHEL \\ \\ \quad ---}} & \specialcell{Red Hat, \\ Inc.} \\
\cdashline{1-2}[.4pt/1pt]
& & \\
& & \\
& & \\
\hline
Slackware & --- & \specialcell{Patrick \\ Volkerding} \\
\hline
\end{tabular}
\end{table}
\end{Spacing}

\end{document}


Note how I've dropped the center environment in lieu of \centering. See Should I use center or centering for figures and tables?

-
Cool. What's the difference between \small and \begin{small}...\end{small} here? I've seen this elsewhere too that someone recommended a {\small...} structure over \begin{small}...\end{small}? –  Lover of Structure Jan 1 '13 at 1:59
@LoverofStructure Take a look at Villemoes’ comment to the answer to the linked question. In short: There is no small environment. –  Qrrbrbirlbel Jan 1 '13 at 2:07
@Qrrbrbirlbel Wow, thanks. Hmm, a lot of instructional materials on the web need to be corrected, don't you think? :-) –  Lover of Structure Jan 1 '13 at 2:15