Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

http://i.stack.imgur.com/nFQI1.png

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).

share|improve this question
    
Welcome to TeX.sx! I uploaded the image for you. –  Torbjørn T. Oct 13 '11 at 6:28

1 Answer 1

up vote 6 down vote accepted

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}

tabularx with correct column lines

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:

booktabs tabularx

share|improve this answer
    
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! –  Luke Morgan 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.