3

I am making a table with some coloured rows, dashed lines and multi rows. There is a set of issues I am running into, and none of them seem to solve my entire problem (only partially).

Below I would like that the rows with "med" and "var" are separated with a dashed line (what I am doing with \cdashline{3-12}). However, when using colors in the cell, the line is covered by the colour. When searching for solution to this, I learned about hhline, which helps with the coloured cells, however, does not seem to provide a dashed line.

Also, I am using makecell because I need to split the line in the row. This makes a weird colour formatting, as the colour does not fill entire cell. I read somewhere about using thead instead, however, my problem remained.

The MWE:

\documentclass{article}
\usepackage{arydshln}
\usepackage{makecell}
\usepackage{hhline}
\usepackage{multirow}
\usepackage{xcolor,colortbl}
\usepackage{array}

\begin{document}

\begin{table}[]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
& \cellcolor[HTML]{EFEFEF} &  & \multicolumn{3}{c|}{A}      & \multicolumn{3}{c|}{B}  & \multicolumn{3}{c|}{C}       \\ \cline{4-12} 
\multirow{-3}{1cm}{\makecell{Onelong-\\word}} & \multirow{-3}{1cm} { \cellcolor[HTML]{EFEFEF} \makecell{ No\\change}} & \multirow{-2}{*}{} & 0.1\%  & 1\%       & 10\%      & 0.1\%  & 1\%     & 10\%      & 0.1\%   & 1\%       & 10\%      \\ \hline
\rowcolor[HTML]{EFEFEF}
&  & med & \makecell{A\\ (B)} & \makecell{C \\  (D)} &  \makecell{ V \\ (D)} &   \makecell{ A \\ (S)} &  T (Y) &  \makecell{Q \\ (A)} &  \makecell{V \\ (V)} &  \makecell{V \\ (V)} &  V (V)  \\  \cdashline{3-12} 

\multicolumn{1}{|p{1cm}|}{\multirow{-2}{*}{\cellcolor[HTML]{EFEFEF}none}}  &   \multirow{-2}{*}{\cellcolor[HTML]{EFEFEF}A (B)} & \cellcolor[HTML]{EFEFEF} var & \cellcolor[HTML]{EFEFEF} \makecell{A \\ (B)} & \cellcolor[HTML]{EFEFEF} \makecell{A \\ (B)} & \cellcolor[HTML]{EFEFEF} \makecell{C \\ (D)} & \cellcolor[HTML]{EFEFEF} \makecell{E\\ (F)} & \cellcolor[HTML]{EFEFEF} \makecell{B \\ (F)} &  \cellcolor[HTML]{EFEFEF} \makecell{C \\ (F)} & \cellcolor[HTML]{EFEFEF}  \makecell{J \\ (G)} & \cellcolor[HTML]{EFEFEF} \makecell{L \\ (H)} & \cellcolor[HTML]{EFEFEF} \makecell{K \\ (B)} \\ \hline   
\end{tabular}
\end{table}
\end{document}

Provides me with: MWE Table example

  • Welcome to TeX - LaTeX! Do you really need all of this? Please read the documentation of the booktabs package for advice on good design of tables. – Andrew Swann Nov 27 '18 at 16:02
  • Hello! Thank you for this reference. The table I am providing here is just a snippet of my entire table. This seems to be the most concise way to show my results. But reading your reference makes me think whether I want to reconsider some of the formatting. – stysia Nov 28 '18 at 17:26
  • The reason I want to grey this particular row and particular column is because I would like to highlight it and refer to it later in the text. In the reference you provided it tells about the best way to present a table. Do you have some similar guide for accenting things in a table? – stysia Nov 29 '18 at 6:59
3

I would suggest a simpler layout, no vertical rules, extra row spacing instead of dashed lines, entries at the top of their cells not multirow. Entries can be highlighted by changing font:

Sample output

here I have chosen \itshape, but \bfseries could be used; or you could use a row color:

Sample with row color

\documentclass{article}

\usepackage{booktabs}
\usepackage{xcolor,colortbl}

\definecolor{hrow}{HTML}{EFEFEF}
\newcommand{\hi}{\itshape}

\begin{document}

\begin{tabular}{*{12}{c}}
  \toprule
  \smash{\begin{tabular}[t]{@{}c@{}}Onelong-\\word \end{tabular}}
  &\smash{\begin{tabular}[t]{@{}c@{}}No\\change \end{tabular}}
  &
  &\multicolumn{3}{c}{A}
  &\multicolumn{3}{c}{B}
  &\multicolumn{3}{c}{C}\\
  \cmidrule(lr){4-6}
  \cmidrule(lr){7-9}
  \cmidrule(lr){10-12}
  &&
  &0.1\%&1\%&10\%
  &0.1\%&1\%&10\%
        &0.1\%&1\%&10\%\\
  \midrule
  none&A(B)&med&A&C&V&A&T(Y)&Q&V&V&V(V)\\
  &&&(B)&(D)&(D)&(S)&&(A)&(V)&(V)&\\[.5ex]
  &&var&A&A&C&E&B&C&J&L&K\\
  &&&(B)&(B)&(D)&(F)&(F)&(F)&(G)&(H)&(B)\\
  \midrule
  \hi one&\hi A(B)&\hi med&\hi A&\hi C&\hi V&\hi A&\hi T(Y)&\hi Q&\hi V&\hi V&\hi V(V)\\
  \hi &&&\hi (B)&\hi (D)&\hi (D)&\hi (S)&&\hi (A)&\hi (V)&\hi (V)&\\[.5ex]
  \hi &&\hi var&\hi A&\hi A&\hi C&\hi E&\hi B&\hi C&\hi J&\hi L&\hi K\\
  \hi &&&\hi (B)&\hi (B)&\hi (D)&\hi (F)&\hi (F)&\hi (F)&\hi (G)&\hi (H)&\hi (B)\\
  \midrule
  two&A(B)&med&A&C&V&A&T(Y)&Q&V&V&V(V)\\
  &&&(B)&(D)&(D)&(S)&&(A)&(V)&(V)&\\[.5ex]
  &&var&A&A&C&E&B&C&J&L&K\\
  &&&(B)&(B)&(D)&(F)&(F)&(F)&(G)&(H)&(B)\\
  \bottomrule
\end{tabular}

\clearpage

\begin{tabular}{*{12}{c}}
  \toprule
  \smash{\begin{tabular}[t]{@{}c@{}}Onelong-\\word \end{tabular}}
  &\smash{\begin{tabular}[t]{@{}c@{}}No\\change \end{tabular}}
  &
  &\multicolumn{3}{c}{A}
  &\multicolumn{3}{c}{B}
  &\multicolumn{3}{c}{C}\\
  \cmidrule(lr){4-6}
  \cmidrule(lr){7-9}
  \cmidrule(lr){10-12}
  &&
  &0.1\%&1\%&10\%
  &0.1\%&1\%&10\%
  &0.1\%&1\%&10\%\\
  \midrule
  none&A(B)&med&A&C&V&A&T(Y)&Q&V&V&V(V)\\
  &&&(B)&(D)&(D)&(S)&&(A)&(V)&(V)&\\[.5ex]
  &&var&A&A&C&E&B&C&J&L&K\\
  &&&(B)&(B)&(D)&(F)&(F)&(F)&(G)&(H)&(B)\\
  \midrule
  \rowcolor{hrow} one&A(B)&med&A&C&V&A&T(Y)&Q&V&V&V(V)\\
  \rowcolor{hrow} &&&(B)&(D)&(D)&(S)&&(A)&(V)&(V)&\\[.5ex]
  \rowcolor{hrow} &&var&A&A&C&E&B&C&J&L&K\\
  \rowcolor{hrow} &&&(B)&(B)&(D)&(F)&(F)&(F)&(G)&(H)&(B)\\
  \midrule
  two&A(B)&med&A&C&V&A&T(Y)&Q&V&V&V(V)\\
  &&&(B)&(D)&(D)&(S)&&(A)&(V)&(V)&\\[.5ex]
  &&var&A&A&C&E&B&C&J&L&K\\
  &&&(B)&(B)&(D)&(F)&(F)&(F)&(G)&(H)&(B)\\
  \bottomrule
\end{tabular}

\end{document}
  • Wow, this looks very pleasing! Thank you for the tip on the highlighting. I think the cell colour looks nicer than emphsise/italics. I mentioned also that I was interested in highlighting both the column and the row. However, I think maybe I could skip the column and somehow emphasise the information I need in the text, and only focus on the row. Also, I like the midrules for the A, B, C elements. I learned a lot, thank you! – stysia Nov 29 '18 at 16:09

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.