2

I have a very large table includes results of 4 different methods, and my supervisor suggested me to use vertical lines to separate methods for readability. However, when I use vertical dashed lines they are not continuous, and as I understand this is a very common problem in booktabs environment. Generally, the suggested solution is not to use vertical lines, but I want to use it. Is there any workaround? I am also open your suggestions to improve readability.

Here is the working example. Sorry for the meaningless column names.

\documentclass[journal]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage{amsmath} % assumes amsmath package installed
\usepackage{amssymb} 
\usepackage{caption}
\usepackage{tabularx, booktabs}

\usepackage{arydshln}


\begin{document}

\begin{table*}
\caption{a $\rightarrow$ b}
\label{tabAB}
\begin{tabularx}{\textwidth}{@{\extracolsep{\fill}}ccc:cccc:cccc:cccc}
\toprule
 & \multicolumn{2}{c}{\begin{tabular}[c]{@{}c@{}}a \\ b \end{tabular}} & \multicolumn{4}{c}{\begin{tabular}[c]{@{}c@{}}c \\$\downarrow$\\ d \end{tabular}} & \multicolumn{4}{c}{\begin{tabular}[c]{@{}c@{}}e \\ $\downarrow$\\ f \end{tabular}} & \multicolumn{4}{c}{\begin{tabular}[c]{@{}c@{}}g \\ $\downarrow$\\ h \end{tabular}}\\ 
& & & \multicolumn{2}{c}{q} & \multicolumn{2}{c}{w} & \multicolumn{2}{c}{e} & \multicolumn{2}{c}{r} & \multicolumn{2}{c}{t} & \multicolumn{2}{c}{y}\\
\cmidrule(lr){2-15}
 & u & w & \begin{tabular}[c]{@{}c@{}}a\\ b \end{tabular} & \begin{tabular}[c]{@{}c@{}}c.\\ d \end{tabular} & \begin{tabular}[c]{@{}c@{}}e.\\ f \end{tabular} & \begin{tabular}[c]{@{}c@{}}h.\\ g \end{tabular} & \begin{tabular}[c]{@{}c@{}}j.\\ j \end{tabular}  & \begin{tabular}[c]{@{}c@{}}k.\\ t \end{tabular} & \begin{tabular}[c]{@{}c@{}}y.\\ v \end{tabular} & \begin{tabular}[c]{@{}c@{}}z.\\ w \end{tabular} & \begin{tabular}[c]{@{}c@{}}q.\\ w \end{tabular} & \begin{tabular}[c]{@{}c@{}}a.\\ t \end{tabular} & \begin{tabular}[c]{@{}c@{}}y.\\ u \end{tabular} & \begin{tabular}[c]{@{}c@{}}z.\\ x \end{tabular} \\ \hline\\
\begin{tabular}[c]{@{}c@{}}q\\ a No \\\ t \end{tabular} & & \multicolumn{13}{c}{err(\%)} \\
\cmidrule(lr){2-15}
1        & 1.33  & 1.10 & 2.43 & 1.92 & 1.57 & 1.79 & 1.58  & 1.57 & 1.19 & 1.77 & 1.42 & 1.41 & 1.89 & \textbf{1.52} \\
2        & 2.48  & 2.53 & 2.60 & 2.31 & 2.82 & 2.80 & 2.84  & 2.82 & 2.50 & 2.79 & 2.60 & 2.59 & 2.13 & \textbf{2.51} \\
3        & 2.94  & 2.75 & 2.90 & 2.46 & 4.82 & 3.48 & 2.83  & 4.82 & 2.30 & 2.45 & 3.78 & 2.77 & 2.41 & \textbf{2.67} \\
4        & 3.36  & 3.53 & 3.45 & 0.54 & 9.69 & 2.34 & 2.70  & 2.68 & 2.17 & \textbf{2.28} & 3.53 & 3.52 & 2.03 & 2.30 \\
5        & \textbf{2.38}  & 2.65 & 3.60 & 2.32 & 2.31 & 2.10 & 2.34  & 2.31 & 4.92 & 2.05 & 2.81 & 2.78 & 2.08 & 2.33 \\\\
Overall        & 2.90  & 2.11 &  2.80 & 2.11 & 2.84 & 2.30 & 3.86  & 3.84 & 2.02 & 2.27 & 2.23 & 3.21 & 2.51 & \textbf{2.87} \\\\
\begin{tabular}[c]{@{}c@{}}t\\ w \end{tabular} & \textbf{1.55} & 1.88 & 2.09 & 1.59 & 1.15 & 1.01 & 1.15 & 1.15 & 1.64 & 1.98 & 1.85 & 1.85 & 1.24 & 1.68 \\
\bottomrule

\end{tabularx}
\end{table*}

\end{document}

discont.

Dashed lines should continue from the first row to the end.

  • 1
    Don't use booktabs or don't use vertical rules. Have you read booktabs's manual? Its author is absolutely opposed to vertical rules under all cricumstances. Well, OK, only in tables (as far as I know). The manual is a kind of one-author propaganda/public information campaign against them and the package is that author's form of guerilla warfare. The view may be extreme, but it is passionately held. To use vertical rules in conjunction with booktabs's macros is to turn up at the pearly gates not only having supped with the devil, but still drunkenly clinging to his arm. Not a chance. – cfr Feb 16 '18 at 2:44
  • 1
    Moreover, the view is 99.999% reasonable. If you are truly faced with one of the 0.0001% of cases in which vertical rules will really benefit the table, don't use booktabs. makecell is a possible alternative, which you can configure to match booktabs's spacing in other tables, if required. It is more work than booktabs, but gives somewhat finer-grained control over some aspects of your tables. It tolerates vertical rules. – cfr Feb 16 '18 at 2:48
  • 1
    Actually, if you really want vertical rules, I think I'd draw it as a TikZ matrix. Usually, I think that's overkill for tables, but this might just be a case where it is justified. However, see what Bernard suggests first. – cfr Feb 16 '18 at 3:21
  • 1
    @cfr - I've posted an answer that uses no vertical rules (while still using the booktabs package, naturally). The key is to provide more visual structure to the header material, done here by inserting various \cmidrule directives. – Mico Feb 16 '18 at 6:11
  • 1
    Or what @Mico suggests ... :-). For some reason, tables just makes me think of Bernard. – cfr Feb 17 '18 at 0:16
4

Here's a solution that does away with the need for (dashed or continuous) vertical lines. It does so by providing more structure, via judiciously placed \cmidrule directives, in the header material. It also switches from a tabularx to a tabular* environment; making this switch is indicated because there doesn't seem to be any need for automatic line breaking within cells.

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,caption,booktabs}
%% Handy shortcut macro:
\newcommand\mytab[1]{\begin{tabular}[c]{@{}c@{}} #1 \end{tabular}}

\begin{document}

\begin{table*}
\caption{a$\to$b} \label{tabAB}
\setlength\tabcolsep{0pt} % let LaTeX figure out intecol. whitespace
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{15}{c} }
\toprule
 \mytab{q\\a No\\t} 
 & \multicolumn{2}{c}{\mytab{a\\$\downarrow$\\ b}} 
 & \multicolumn{4}{c}{\mytab{c\\$\downarrow$\\ d}}  
 & \multicolumn{4}{c}{\mytab{e\\$\downarrow$\\ f}}
 & \multicolumn{4}{c}{\mytab{g\\$\downarrow$\\ h}}\\ 
\cmidrule{4-7} \cmidrule{8-11} \cmidrule{12-15} 
& & & \multicolumn{2}{c}{q} & \multicolumn{2}{c}{w} 
    & \multicolumn{2}{c}{e} & \multicolumn{2}{c}{r} 
    & \multicolumn{2}{c}{t} & \multicolumn{2}{c}{y}\\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} 
\cmidrule{10-11} \cmidrule{12-13} \cmidrule{14-15} 
 & u & w 
 & \mytab{a\\b} & \mytab{c.\\d} & \mytab{e.\\f} & \mytab{h.\\g} 
 & \mytab{j.\\j}& \mytab{k.\\t} & \mytab{y.\\v} & \mytab{z.\\w} 
 & \mytab{q.\\w}& \mytab{a.\\t} & \mytab{y.\\u} & \mytab{z.\\x}\\
\midrule
 & \multicolumn{14}{c}{err(\%)} \\
\cmidrule{2-15}
1  & 1.33  & 1.10 & 2.43 & 1.92 & 1.57 & 1.79 & 1.58  & 1.57 
   & 1.19 & 1.77 & 1.42 & 1.41 & 1.89 & \textbf{1.52} \\
2  & 2.48  & 2.53 & 2.60 & 2.31 & 2.82 & 2.80 & 2.84  & 2.82 
   & 2.50 & 2.79 & 2.60 & 2.59 & 2.13 & \textbf{2.51} \\
3  & 2.94  & 2.75 & 2.90 & 2.46 & 4.82 & 3.48 & 2.83  & 4.82 
   & 2.30 & 2.45 & 3.78 & 2.77 & 2.41 & \textbf{2.67} \\
4  & 3.36  & 3.53 & 3.45 & 0.54 & 9.69 & 2.34 & 2.70  & 2.68 
   & 2.17 & \textbf{2.28} & 3.53 & 3.52 & 2.03 & 2.30 \\
5  & \textbf{2.38}  & 2.65 & 3.60 & 2.32 & 2.31 & 2.10 & 2.34  
   & 2.31 & 4.92 & 2.05 & 2.81 & 2.78 & 2.08 & 2.33 \\[1ex]
Overall  & 2.90  & 2.11 &  2.80 & 2.11 & 2.84 & 2.30 & 3.86  
   & 3.84 & 2.02 & 2.27 & 2.23 & 3.21 & 2.51 & \textbf{2.87} \\[1ex]
\mytab{t\\w} & \textbf{1.55} & 1.88 & 2.09 & 1.59 & 1.15 & 1.01 & 1.15 
   & 1.15 & 1.64 & 1.98 & 1.85 & 1.85 & 1.24 & 1.68 \\
\bottomrule
\end{tabular*}
\end{table*}

\end{document}
  • 1
    Much better than what I tried to come up with. – cfr Feb 17 '18 at 0:17

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.