1

Sorry for the very specific question, I have been struggling with tables a fair amount recently!

I have produced the following table in LaTeX: enter image description here which has the following code:

\documentclass[12pt]{article}

\usepackage{array}
\usepackage[justification=centering]{caption}

\renewcommand{\h}{\hline\hline}

\begin{document} 

\begin{table}[h!] \centering
\setlength\extrarowheight{2pt}
\begin{tabular}{|b{0.17\paperwidth}||b{0.16\paperwidth}|b{0.16\paperwidth}|b{0.16\paperwidth}|b{0.16\paperwidth}|}
\hline   & \multicolumn{4}{c|}{Title of columns 2-5} \\
\h Column 1                & Column 2        & Column 3      & Column 4        & Column 5 \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline
\end{tabular}
\caption{The caption of my table}
\label{label}
\end{table} 

\end{document}

(Please ignore the apparently thicker lines as seen between rows 5 and 6, as well as between columns 1 and 2, this is just an issue with my pdf displayer.)

A minor aesthetic change which I would like to make is to remove the joining line between the || between column and the multicolumn in the first row; ie, I'd like to go from this: enter image description here to something which looks like this: enter image description here

I am aware this is quite a 'lazy' question, however I am totally unfamiliar with LaTeX tables (any suggested reading/watching to help me learn is greatly appreciated as well!), so any help at all would be brilliant. Because of how specific my title was, I was unable to find any similar questions on SE, however if there are any they would also be greatly appreciated (I was also unsure exactly what to tag this post as related to).

Thanks very much! :)


NB: often I see peoples' solutions to these problems involve simply redesigning the table in another style; if it is possible please could this be avoided, as this table style is consistent with the aesthetic of my document (I can't be the only one who thinks lines between columns are a good thing...).

  • hhline package is your friend – David Carlisle Oct 26 '17 at 12:16
  • Words from the creator himself! Thanks: I'll have a look. – aidangallagher4 Oct 26 '17 at 12:18
1

Just so this question can have an answer for others' future reference, using the hhline package, here is the solution I reached:

\documentclass[12pt]{article}

\usepackage{array}
\usepackage{hhline}

\begin{document}

\begin{table}[h!] \centering
\setlength\extrarowheight{2pt}
\begin{tabular}{|b{0.17\paperwidth}||b{0.16\paperwidth}|b{0.16\paperwidth}|b{0.16\paperwidth}|b{0.16\paperwidth}|}\hhline{-||----}
                  & \multicolumn{4}{c|}{Title of columns 2-5} \\ \hhline{=b:b:b====}
Column 1                & Column 2        & Column 3      & Column 4        & Column 5 \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline xx                  & xxx             & xxx           & xxx             & xxx \\
\hline
\end{tabular}
\caption{The caption of my table}
\label{label}
\end{table} 

\end{document}

Which gives: enter image description here

Thanks very much to David Carlisle for pointing me in the right direction (and indeed writing the package in the first place)!

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.