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 have a situation similar as to this MWE:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}
\begin{tiny}
\begin{tabularx}{\textwidth}{|>{\normalsize}X|X|X|}
\hline
Foo & Bar & Baz\\
\hline
\end{tabularx}
\end{tiny}
\end{table}
\end{document}

I.e., I have a first column with a larger fontsize than the others.

The text is vertically aligned along the baseline, which leads to somewhat ugly whitespace at the top of the table cells. (In my real document, those cells hold multiple lines of text, which makes the effect even more ugly.)

How do I make the text align so that the normalsize and tiny cells have the same whitespace from the top of the table cell?

Google led me to raisebox, with which I did some experiments but somehow couldn't get a satisfactory result...

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

Inserting zero vertical space helps with aligning at the top:

\newcolumntype{V}{>{\vspace{0pt}}X}

Your complete example, with also \Huge text to see the effect:

\documentclass{article}
\usepackage{tabularx}
\newcolumntype{V}{>{\vspace{0pt}}X}
\begin{document}
\begin{table}
\tiny
\begin{tabularx}{\textwidth}{|>{\normalsize}V|V|>{\Huge}V|}
\hline
Foo & Bar & Baz\\
\hline
\end{tabularx}
\end{table}
\end{document}

vertically top aligned cells

share|improve this answer
    
This is really nice. And so simple. (+1) –  Thorsten Donig Dec 21 '11 at 21:37
add comment

You could give the tabu package a try.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tabu}

\setlength{\extrarowsep}{6pt}

\begin{document}
  \begin{table}[!ht]
    \tiny
    \begin{tabu} to \textwidth {|>{\normalsize}X[m]|X[m]|X[m]|}\hline
      Foo & Bar & Baz \\\hline
    \end{tabu}
  \end{table}
\end{document}

The package is not perfect (especially not its manual), but I think it is a good start.

share|improve this answer
    
As I see now, this solution is not completely what you are looking for. It aligns all columns vertically to the center of the cells. –  Thorsten Donig Dec 21 '11 at 20:09
    
Yes... but if no better solution presents itself, vertically-centered is acceptable. –  DevSolar Dec 21 '11 at 20:19
add comment
\documentclass{article}
\usepackage{tabularx,lipsum}
\begin{document}
\begin{table}
\tiny
\begin{tabularx}{\textwidth}{
 |>{\normalsize\hrule height0pt\kern-2pt}X
 |>{\hrule height0pt\kern-2pt}X
 |>{\hrule height0pt\kern-2pt}X|}
\hline
Foo & \lipsum*[2] & \lipsum*[3]\\
\hline
\end{tabularx}
\end{table}
\end{document}

Adjust the dimension after the \kern command until you're satisfied. The trick is to make the reference point of the cells the upper corner with the phantom rule.

share|improve this answer
add comment

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.