3

I use tabu and makecell to create tables and their content. As many other people I want to align cell content top-left. There are a lot of postings about that topic (with different table environments) on the web. It looks like that there is no easy solution for it. There are only a lot of tricks and workarounds with \raisebox etc.

So the question is if there is an easy way or is it not possible with a real solution (means no tricks and workarounds). I imagine a simple [t,l] as column option or something like that.

Here is a minimal example

\documentclass{article}
\usepackage{xltxtra}

\usepackage{tabu}
\usepackage{makecell}

\begin{document}
\noindent
\begin{tabu*} spread \textwidth {|X|X|}
    \tabucline{-}
    \makecell{top left}&\makecell{normal\\text\\also top\\left}\\
    \tabucline{-}
\end{tabu*}
\end{document}
  • 1
    If I remove makecell and use of its macro \makecell{...} I get result as you desired (text is on the top and justified). Why you need makecell ? – Zarko Jul 10 '16 at 7:38
6

As I said in my comment,it is no clear why you use \makecell{...}. Top left align is easy to achieve without it. If you still persist to use it, than you need to add option [tl] for top align and ragged text an right side:

\makecell[tl]{...}

MWE, which show result without use of makecell{..} (in the first row) and with it (second row) is:

\documentclass{article}
\usepackage{xltxtra}

\usepackage{tabu}
\usepackage{makecell}

\begin{document}
\noindent
\begin{tabu*} spread \textwidth {|X[l]|X|}
    \tabucline{-}
top left longer text top left longer text top left longer text top left longer text top left longer text top left longer text top left longer text top left longer text 
    &   normal\newline text\newline also top\newline left   \\
    \tabucline{-}
\makecell[tl]{top left}
    &   \makecell[tl]{normal\\ text\\ also top\\ left}   \\
    \tabucline{-}
\end{tabu*}
\end{document}

enter image description here

  • great. behave as expcected. I have to check if something in my real code create side affects here. Thank you very much. – buhtz Jul 10 '16 at 21:15
  • The t option is not in the documentation of makecell. That was the point. – buhtz Jul 12 '16 at 7:58
  • 1
    It is described on page 3.: ... This will be useful for creation of multilined cells. This macro allows optional alignment settings. \makecell[hvertical or/and horizontal alignmenti]{hcell texti} For vertical alignment you use t, b, or c|this letters you usually put in optional argument of tabular or array environments. For horizontal alignment you may use alignment settings like r, l, or c, or more complex, like {p{3cm}}. Since this package loads array package, you may use such alignment settings like {>\parindent1cm}p{3cm}}˙`. – Zarko Jul 12 '16 at 8:21
  • I should stop doing such things in the middle of the night. – buhtz Jul 12 '16 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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