2

I'm having this beautiful answer here Double cell border for table (for an entire column) using the hhline package and want to get even further in terms of layout aspects.

The current code by @StefanH is:

\documentclass[12pt]{article}
\usepackage{hhline}
\begin{document}
\begin{tabular}{|c||c|c|c|}  
  \hhline{-||---}
  & headline1 & headline2 & headline3 \\ 
  \hhline{=::===}
  row1 & a & b & c \\ 
  \hhline{-||---}
  row2 & d & e & f \\ 
  \hhline{-||---}
  row3 & g & h & i \\ 
  \hhline{-||---}
\end{tabular} 
\end{document}

but I want to get even further and having the top left cell hidden/without borders so it should look s.th. like this: enter image description here

I managed it using the following code:

\documentclass[12pt]{article}
\usepackage{hhline}
\begin{document}
\begin{tabular}{|c||c|c|c|} 
  \hhline{~|---}
 \multicolumn{1}{c|}{} & headline1 & headline2 & headline3 \\ 
  \hhline{-::===}
  row1 & a & b & c \\ 
  \hhline{-||---}
  row2 & d & e & f \\ 
  \hhline{-||---}
  row3 & g & h & i \\ 
  \hhline{-||---}
\end{tabular} 
\end{document}

But, if you might see, there is an little dot (leftover from the border) which I would like to hide as well:

enter image description here

any idea how to get rid of it?

  • more professional look of your table you will obtain with \documentclass[12pt]{article} \usepackage{booktabs} \begin{document} \begin{tabular}{*{4}{c}} \toprule & headline1 & headline2 & headline3 \\ \midrule row1 & a & b & c \\ row2 & d & e & f \\ row3 & g & h & i \\ \bottomrule \end{tabular} \end{document} – Zarko Jun 6 '17 at 18:22
  • well ok, but I think for "my" real data (not this fake entries) it gets a bit unclear due to the amount rows and columns in the table. but thx anyway. Or is there may a way to highlight/seperate the first column as in my example? – user1234 Jun 6 '17 at 18:28
  • @user2798895 I agree with @Zarko with respect to the table: vertical separators are especially bad to be read and seem unprofessional. I think that, if you want to enhance readability of long tables or possibly single out some column, you could use different shades of grey, with the colortbl package – Moriambar Jun 6 '17 at 18:44
  • 1
    that is not true. with linnes the table is not more clear ... However, for example after each fith row you can add \addlinespace – Zarko Jun 6 '17 at 18:44
2

I won't say what kind of tabular looks best, but I will try to help you cover up the unsightly dot. I did it by adding the line between row1 and the subsequent & separator. It had to be added there, because it is the 2nd row of code that is laying down that dot in the 1st row. What I did is lay down a zero-width, \smashed \rule that covers up the dot. I did it in red!5 so you can see the impact of it. Change that color to white and you are good to go. The 14pt may need adjustment depending on the width of the cell contents.

\documentclass[12pt]{article}
\usepackage{hhline,xcolor}
\begin{document}
\begin{tabular}{|c||c|c|c|} 
  \hhline{~|---}
 \multicolumn{1}{c|}{} & headline1 & headline2 & headline3 \\ 
  \hhline{-::===}
  row1 
% THE FOLLOWING LINE WAS ADDED, CHANGE red!5 TO white, ALTER 14pt TO SUIT DATA
  \unskip\textcolor{red!5}{\makebox[0pt]{\smash{\rule[12pt]{14pt}{3pt}}}}
%
   & a & b & c \\ 
  \hhline{-||---}
  row2 & d & e & f \\ 
  \hhline{-||---}
  row3 & g & h & i \\ 
  \hhline{-||---}
\end{tabular} 
\end{document}

enter image description here

An alternate method is to leave the tabular as you had it and \stackinset a \rule over the complete tabular, from the upper left:

\documentclass[12pt]{article}
\usepackage{hhline,xcolor,stackengine}
\begin{document}
\stackinset{l}{}{t}{}{\textcolor{red!5}{\rule{37pt}{16pt}}}{%
\begin{tabular}{|c||c|c|c|} 
  \hhline{~|---}
 \multicolumn{1}{c|}{} & headline1 & headline2 & headline3 \\ 
  \hhline{-::===}
  row1 
   & a & b & c \\ 
  \hhline{-||---}
  row2 & d & e & f \\ 
  \hhline{-||---}
  row3 & g & h & i \\ 
  \hhline{-||---}
\end{tabular}%
}
\end{document}

enter image description here

As long as the first row remains a single line, a macro can be set up to help. In this case, \coverup{<widest col1 entry>}{<original tabular>} can be invoked.

\documentclass[12pt]{article}
\usepackage{hhline,xcolor,stackengine}
\newcommand\coverup[2]{%
  \stackinset{l}{\fboxrule}{t}{2\fboxrule}{\fboxsep=0pt\colorbox{red!5}{%
    \kern2\tabcolsep \phantom{#1}\strut}}{\ignorespaces#2\unskip}}
\begin{document}
\coverup{row1}{
\begin{tabular}{|c||c|c|c|} 
  \hhline{~|---}
 \multicolumn{1}{c|}{} & headline1 & headline2 & headline3 \\ 
  \hhline{-::===}
  row1 
   & a & b & c \\ 
  \hhline{-||---}
  row2 & d & e & f \\ 
  \hhline{-||---}
  row3 & g & h & i \\ 
  \hhline{-||---}
\end{tabular}
}
\end{document}
| improve this answer | |
0

Please, take a brake and see Less is more. Considering this in design of your table, you can get:

enter image description here

Is above table really less readable than yours?

\documentclass[12pt]{article} 
\usepackage{booktabs} 

\begin{document} 
\begin{tabular}{*{4}{l}} 
    \toprule 
        & headline1 & headline2 & headline3 \\ 
    \midrule 
row 1   & aaaaaaaa  & bbbbbbbb  & ccccccc   \\ 
row 2   & dddddddd  & eeeeeeee  & ffffffff  \\ 
row 3   & gggggggg  & hhhhhhhh  & iiiiiiii  \\
row 4   & jjjjjjjj  & kkkkkkkk  & llllllll  \\
row 5   & mmmmmmmm  & nnnnnnnn  & oooooooo  \\
    \addlinespace
row 1   & aaaaaaaa  & bbbbbbbb  & ccccccc   \\
row 2   & dddddddd  & eeeeeeee  & ffffffff  \\
row 3   & gggggggg  & hhhhhhhh  & iiiiiiii  \\
row 4   & jjjjjjjj  & kkkkkkkk  & llllllll  \\
row 5   & mmmmmmmm  & nnnnnnnn  & oooooooo  \\
    \addlinespace
row 1   & aaaaaaaa  & bbbbbbbb  & ccccccc   \\
row 2   & dddddddd  & eeeeeeee  & ffffffff  \\
row 3   & gggggggg  & hhhhhhhh  & iiiiiiii  \\
row 4   & jjjjjjjj  & kkkkkkkk  & llllllll  \\
row 5   & mmmmmmmm  & nnnnnnnn  & oooooooo  \\
    \bottomrule 
\end{tabular} 
\end{document}
| improve this answer | |
  • yes I agree this sample looks good. But insted of row1-row3 I habe longer text / more than one word. Eg. row1=two line of text; row2=one line of text and row3=three lines of text. Without borders it looks very odd. – user1234 Jun 6 '17 at 20:38
  • Well, I strongly disagree with you. But, if you like to have ugly table, than I will not try anymore to convince to opposite :) . By the way, do you take a time and look in given link? – Zarko Jun 6 '17 at 20:47
0

Here are two other possibilities, a little more decorative:

\documentclass[12pt]{article}
\usepackage[table, svgnames]{xcolor}
\usepackage{hhline, booktabs}

\begin{document}

\begin{tabular}{| >{\columncolor{Gainsboro!50!Lavender}}l||c|c|c|}
\hhline{~|---|}
\rowcolor{Gainsboro!50!Lavender} \multicolumn{1}{c!{}|}{\cellcolor{PapayaWhip}} & \multicolumn{1}{c}{headline1} & headline2 & headline3 \\
  \hhline{->{\arrayrulecolor{white}}t :>{\arrayrulecolor{black}}:>{\arrayrulecolor{black}}===:}
   row1 & a & b & c \\
  \hhline{-||---|}
  row2 & d & e & f \\
  \hhline{-||---|}
  row3 & g & h & i \\
  \hhline{-||---|}
\end{tabular}
\vspace{1cm}

\setlength\extrarowheight{2pt}
\setlength{\arrayrulewidth}{0.6pt}
\arrayrulecolor{Gainsboro!50!Lavender}
\begin{tabular}{>{\columncolor{Gainsboro!50!Lavender}}l|!{\color{RoyalBlue}\vrule width 0.6pt}c|c|c!{\color{RoyalBlue}\vrule width 0.6pt}}
\rowcolor{Gainsboro!50!Lavender} \multicolumn{1}{c!{\hspace{\dimexpr\doublerulesep + \arrayrulewidth}}}{\cellcolor{PapayaWhip}} & \multicolumn{1}{!{\hspace{-\arrayrulewidth}}c}{headline1} & \multicolumn{1}{c}{headline2} &\multicolumn{1}{c}{ headline3} \\\addlinespace[0.5ex]
\hhline{-|>{\arrayrulecolor{RoyalBlue}}|---|}
row1 & a & b & c \\
\hhline{>{\arrayrulecolor{Gainsboro!50!Lavender}}-|>{\arrayrulecolor{RoyalBlue}}|---|}
  row2 & d & e & f \\
\hhline{>{\arrayrulecolor{Gainsboro!50!Lavender}}-|>{\arrayrulecolor{RoyalBlue}}|---|}
 row3 & g & h & i \\
\hhline{>{\arrayrulecolor{Gainsboro!50!Lavender}}-|>{\arrayrulecolor{RoyalBlue}}|---|}
\end{tabular}

\end{document} 

enter image description here

| improve this answer | |

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.