Graphics, Figures & TablesTable columns width: still not working (strange behaviour)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Raindancer
Posts: 1
Joined: Wed May 26, 2010 8:03 am

Table columns width: still not working (strange behaviour)

Post by Raindancer »

Hi, I am working on a very simple table but after have read so much documents, tutorial and examples I am still not able to realize the table I want.

I want to create just a table with three column, the first containing a short code, the second and the third a long text.

So I tried with that (and a million variations):

Code: Select all

\begin{table}
\caption{Research Questions}
\centering
\begin{tabular}{|c|lp{15em}|lp{15em}|}
\hline
& \bf{Question} & \bf{Motivation} \\ [0.5ex]
\hline \hline
\bf{RQ1} & Which journals include papers on web applications modeling? & Support web applications modeling researchers with a list of journals with potentially relevant papers.\\
  \hline

\end{tabular}
\label{table:rqs}
\end{table}
So I would expect to have the second and the third column of the same length. It seems instead that I obtain a very large second columna and a tiny third one.

The strange behaviour is this one: when I change the width supposed to affect the second column the third one is instead changed. In example this code:

Code: Select all

{|c|lp{5em}|lp{15em}|}
reduces the third column.
I really do not get it.
Any help/hint?

Thank you,
Federico

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table columns width: still not working (strange behaviour)

Post by localghost »

Raindancer wrote:[...] I want to create just a table with three column, the first containing a short code, the second and the third a long text. [...]
If you want table with three columns, then why do declare five columns in the table head? With the tabularx package you can have tables across the whole text width with chosen columns calculated automatically.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs,tabularx}

\begin{document}
  \begin{table}[!ht]
    \caption{Research Questions}\label{tab:rqs}
    \centering
    \begin{tabularx}{\linewidth}{cXX}\toprule
    & \textbf{Question} & \textbf{Motivation} \\ \midrule
    \textbf{RQ1} & Which journals include papers on web applications modeling? & Support web applications modeling researchers with a list of journals with potentially relevant papers. \\ \bottomrule
    \end{tabularx}
  \end{table}
\end{document} 
It is recommendable to drop vertical lines in order to improve the legibility of the table. The booktabs package allows to typeset nice looking tables.


Best regards and welcome to the board
Thorsten
Post Reply