Text FormattingTabularx vertical align

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
byraul
Posts: 2
Joined: Mon Jun 06, 2011 3:10 pm

Tabularx vertical align

Post by byraul »

Hello,
I have a problem with a table. The problem is that the first label is long and I have to use tabularx with X argument for the first column to wrap the text, but then I don't know how to align the other labels in the table header vertically to look nice.

Here is the code and a screenshot. Thank you

Code: Select all

\begin{table}\footnotesize
\begin{tabularx}{\linewidth}{|X|c|c|c|c|c|c|c|}
\hline
\textbf{One long label ssfsfsfsdfsf} & \textbf{two...} & \textbf{threee} & \textbf{fourrrr.....} & \textbf{fiveee sdfsdfs} & \textbf{sixxxxxx} & \textbf{seveeeen} \\ \hline
Blablabla & bla bla00 & blablabla & blablabla & blablaba & blablabla & b;ablaba \\ \hline
Attachments
Screenshot.png
Screenshot.png (5.86 KiB) Viewed 10977 times
Last edited by byraul on Tue Jun 07, 2011 9:29 am, edited 1 time in total.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Tabularx vertical align

Post by Stefan Kottwitz »

Hi byraul,

welcome to the board!

You could use m columns instead of c columns, to achieve vertically centered alignment.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Tabularx vertical align

Post by localghost »

You may try the quite new tabu package.

Code: Select all

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

\begin{document}
  \begin{tabu} spread \linewidth {|X[m]|c|c|c|c|c|c|}\hline
    \rowfont{\bfseries}
    A very long label & 2nd col. & 3rd col. & 4th col. & 5th col. & 6th col. & 7th col. \\ \hline
    Foobar & foobar & foobar & foobar & foobar & foobar & foobar \\ \hline
  \end{tabu}
\end{document}
However, some adjustment might be necessary.


Thorsten
byraul
Posts: 2
Joined: Mon Jun 06, 2011 3:10 pm

Re: Tabularx vertical align

Post by byraul »

thanks guys... resolved with tabu :D
Post Reply