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've a positioning problem in my tabu header. If I define the text color with rowfont, the text in that row will jumping around like a rabbit.

\documentclass[]{scrlttr2}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{colortbl}
\usepackage{tabu}
\usepackage{xcolor}

\definecolor{TableHeaderColor}{HTML}{444444}
\definecolor{TableHeaderBackgroundColor}{HTML}{EEEEEE}

\begin{document}
    \begin{tabu} to \textwidth {c X}
        \rowfont{\bfseries\footnotesize\color{TableHeaderColor}}
        \taburowcolors{TableHeaderBackgroundColor .. TableHeaderBackgroundColor}
        Header & Test \\ \hline
        \taburowcolors{white .. white}
        Bla & bla \\ \hline
        \rowfont{\bfseries\footnotesize\color{TableHeaderColor}}
        \taburowcolors{TableHeaderBackgroundColor .. TableHeaderBackgroundColor}
        Footer & bla
    \end{tabu}

\end{document}

The resoult is the following: enter image description here

Update

According to Gonzalo Medina's answer I did this changes:

\begin{tabu} to \textwidth {X[1,m,c] X[9,m]}

The positioning is still not perfect. The baseline isn't the same.

enter image description here

Update #2

After I added \strut as Gonzalo Medina recommended, I've still the problem if I'm using \usepackage{lmodern}.

enter image description here

share|improve this question
3  
PLease complement your code to a minimal working example (MWE). –  doncherry Oct 14 '12 at 0:22
    
Okay, just a moment. –  Sam Oct 14 '12 at 0:23
    
This seems to be an issue with the column specification X and \rowfont, the baseline of the normal text is used as the top anchor for the X column. –  Qrrbrbirlbel Oct 14 '12 at 0:31
    
How can I fix this issue? –  Sam Oct 14 '12 at 0:32

1 Answer 1

up vote 7 down vote accepted

One option is to change the c column specification; for example:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabu}

\definecolor{TableHeaderColor}{HTML}{444444}
\definecolor{TableHeaderBackgroundColor}{HTML}{EEEEEE}

\begin{document}

\noindent\begin{tabu} to \textwidth {X[1,m,c] X[9,m]}
\rowfont{\strut\bfseries\footnotesize\color{TableHeaderColor}}
\taburowcolors{TableHeaderBackgroundColor .. TableHeaderBackgroundColor}
Header & Testggg \\ \hline
\taburowcolors{white .. white}
Bla & bla \\ \hline
\rowfont{\strut\bfseries\footnotesize\color{TableHeaderColor}}
\taburowcolors{TableHeaderBackgroundColor .. TableHeaderBackgroundColor}
Footer & bla
\end{tabu}

\end{document}

Depending on you actual needs, the specification might need some adjustments.

enter image description here

A test using TikZ to draw a line showing the baseline:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabu}
\usepackage{lmodern}
\usepackage{tikz}

\definecolor{TableHeaderColor}{HTML}{444444}
\definecolor{TableHeaderBackgroundColor}{HTML}{EEEEEE}

\begin{document}

\noindent\begin{tabu} to \textwidth {X[1.5,m,c] X[8.5,m]}
\rowfont{\strut\bfseries\footnotesize\color{TableHeaderColor}}
\taburowcolors{TableHeaderBackgroundColor .. TableHeaderBackgroundColor}
Aufwand & Beschr \\ \hline
\taburowcolors{white .. white}
Bla & bla \\ \hline
\rowfont{\strut\bfseries\footnotesize\color{TableHeaderColor}}
\taburowcolors{TableHeaderBackgroundColor .. TableHeaderBackgroundColor}
Footer & bla
\end{tabu}

\noindent\begin{tikzpicture}[remember picture,overlay]
\draw[red] (0,29.5pt) -- (\textwidth,29.5pt);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thank you for your answer. It helped to fix the problem almost. I've done an update of my question. –  Sam Oct 14 '12 at 0:48
    
@Sam new updated (changing the position of \strut). –  Gonzalo Medina Oct 14 '12 at 1:01
    
Thank you for your update. It works with the given setting. Unfortunately I use another font \usepackage{lmodern}. With that font there is still a difference.. –  Sam Oct 14 '12 at 1:02
    
@Sam sorry, but I can't see the difference using my last updated code. Can you add an example to your question showing the difference? –  Gonzalo Medina Oct 14 '12 at 1:04
    
I've updated my question. –  Sam Oct 14 '12 at 1:08

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.