21

I want to add borders to a set of cells in a table. But not just a border for the single cells because then I imagine I could just put the cell content in an fbox. Instead I want a frame which "merges" some cells. Hm I think I will try some ASCII to show how I mean:

---------------------------------------------------
Col 1    Col 2    Col 3    Col 4    Col 5    Col 6 
---------------------------------------------------
 bla      bla      bla      bla      bla      bla  

 bla      bla      bla      bla      bla      bla  
+---------------------+
|ble      ble      ble|     bla      bla      bla  
+---------------------+
 bla      bla      bla      bla      bla      bla  

I looked into the hhline package but soon realised that it had to do with horizontal lines. It seems very difficult to add those two vertical lines which only are between two cells and do not go all the way through the table. I know that \cline could probably be used for drawing the horizontal lines, but how do I make the vertical ones? (and preferably so it looks good and forms a box, not only four lines with space between them)

29

The horizontal partial lines are done with the \cline command. For the vertical lines you have to use \multicolumn to specify new column properties.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}
  \begin{tabular}{*6{c}}\hline
    Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\\hline
    bla   & bla   & bla   & bla   & bla   & bla \\
    bla   & bla   & bla   & bla   & bla   & bla \\ \cline{1-3}
    \multicolumn{1}{|c}{ble} & ble & \multicolumn{1}{c|}{ble} & bla & bla & bla \\ \cline{1-3}
    bla   & bla   & bla   & bla   & bla   & bla \\ \hline
  \end{tabular}
\end{document}

enter image description here

  • 1
    For the sake of completeness, if you use booktabs, its improved command \cmidrule also takes column numbers as parameters: \cmidline{1-3}. For comparison of \hline and \cline to booktabs's {top,mid,bottom,cmid}rules see this answer. – Ivan Kapitonov May 25 '17 at 0:56

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.