# Vertical line only in one part of a table

I need some help on putting a vertical line in the second part of the table, I don't know how to do it since the tabularx I declared does need to have that only in the second part. The code I used is:

\begin{tabularx}{\linewidth}{|XX|}
\hline
\multicolumn{2}{|c|}{\textbf{title name}}\\
\hline
something: & else \\
something: & else \\
something: & else \\
\hline
\multicolumn{2}{|c|}{bla bla blah}\\
\hline
title text: & description 1 \\
title text: & description 1 \\
\hline
\end{tabularx}

And the render of the table looks like this:

I just need a \vline between title text and description (it I use \vline it works only for the first line but the description text and sometimes the title, are few lines long).

I would just place the respective items in a \multicolumn{1}{|c|}{...}:

\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\begin{tabularx}{\linewidth}{|XX|}
\hline
\multicolumn{2}{|c|}{\textbf{title name}}\\
\hline
something: & else \\
something: & else \\
something: & else \\
\hline
\multicolumn{2}{|c|}{bla bla blah}\\
\hline
\multicolumn{1}{|l|}{title text:} & description 1 \\
\multicolumn{1}{|l|}{title text:} & description 1 \\
\hline
\end{tabularx}
\end{document}

For an improved visual layout of tables, I would suggest using the booktabs package. It provides different horizontal lines (of varying thickness) that neatly separates the table headers and contents. However, due to this, spacing with vertical lines (down a column) is considered problematic. In fact, the booktabs documentation stipulates two main points to consider when making publication-style tables:

1. Never, ever use vertical rules.
2. Never use double rules.

The reason for the first restriction is because table inherently have some horizontal alignment with their columnar structure. As such, adding a vertical line would emphasize the obvious. Here's a mock-up of your original MWE that shows the table using a standard booktabs representation:

• Thanks, it works. But if the title text is too long (I use title text of 2 lines) it just takes all the space. I am now using {|X|} and it works fine! Thanks! Oct 13 '11 at 6:31
• If your title text: is much longer than in your MWE, you can put it in a \parbox{<width>} where you specify the <width>. If this explanation isn't sufficient, please update your original question with an expanded MWE.
– Werner
Oct 13 '11 at 6:39

You can define a macro for placing vline between arbitrary cells:

\def\arrvline{\hfil\kern\arraycolsep\vline\kern-\arraycolsep\hfilneg}

Example:

$$\begin{array}{cccc} a & b \arrvline& c & d\\ f \arrvline& 1asd & 2 & g \\ f & 1asd & 2 & g \\ \end{array}$$

Will produce:

(Probably won't work correctly for right-justified columns)

• Hi @vftdan I am trying to use this solution but noticing the vertical lines don't match up. Is there some way to align them? Please see this question: tex.stackexchange.com/questions/513687/… Oct 27 '19 at 21:32