5

In the docs of the makecell package in Section 1.1 it stated that one can align text horizontally to the top or bottom with \makecell[t]{..} and \makecell[b]{..}. I tried that with

\documentclass{article}
\usepackage{makecell}


\begin{document}
\begin{center}
\begin{tabular}{  l | l l l}

 & Leistung & Stunden & Preis \\
\hline
1. Webdesign &  \makecell[l]{asdads asd asd ada dadadas dasdas d
 \\ asdada sdasdasdasd \\ sdads asd asd ada dadadas dasdas d
 \\ asdada sdasdasdasd \\ sdads asd asd ada dadadas dasdas 
 d \\ asdada sdasdasdasd} 
 & \makecell[t]{Should be top} & \makecell[b]{6Should be bottom}  \\

\end{tabular}
\end{center}

\end{document}

But it does not work. There is no horizontally alignment happening. Why? Thats the result:

enter image description here

4

Your interpretation of the vertical alignment specification is incorrect. Using a [t]op alignment merely sets the anchor point for that specific cell to the baseline of the top\first line of the cell content. Similarly, a [b]ottom alignment sets the anchor point to the baseline of bottom/last line. This doesn't mean that the cell content will be pushed down/up to align with surrounding cells. So

\makecell[t]{%
  one \\% This will be the anchor point
  two \\
  three
}

while

\makecell{%
  one \\
  two \\% This will be the anchor point
  three
}

and

\makecell[b]{%
  one \\
  two \\
  three% This will be the anchor point
}

Here I've highlighted the anchor points to show how they are vertically aligned:

enter image description here

\documentclass{article}

\usepackage{makecell}

\begin{document}

\begin{tabular}{ *{3}{c} }
  \makecell[t]{one \\ two \\ three} &
  \makecell   {one \\ two \\ three} &
  \makecell[b]{one \\ two \\ three}
\end{tabular}

\end{document}

We should be able to gather a number of things from this:

  1. You're specifying an anchor point, not really a vertical alignment with respect to other cells.

  2. The anchor is associated with the \makecell in question, not other cells within the same row.

  3. You can only specify one anchor per cell.

In your example you actually want multiple alignments with column Leistung ([t]op with respect to Stunden and [b]ottom with respect to Preis), and alignments of columns Studen and Preis have no preference since they are only a single line; that is, their vertical anchor will just be the line they're on.

Considering your setup, you can move content up/down using boxes:

enter image description here

\documentclass{article}

\usepackage{makecell}

\begin{document}

\newsavebox{\cellbox}
\savebox{\cellbox}{%
  \makecell[l]{%
    asdads asd asd ada dadadas dasdas d \\
    asdada sdasdasdasd \\
    sdads asd asd ada dadadas dasdas d \\
    asdada sdasdasdasd \\
    sdads asd asd ada dadadas dasdas d \\
    asdada sdasdasdasd}
}%
\begin{tabular}{ l | l l l }
  \hline
  1. Webdesign &
    \usebox{\cellbox} &
    \raisebox{\dimexpr\ht\cellbox-\height}{\makecell{Should be top}} &
    \raisebox{\dimexpr-.5\ht\cellbox-.5\dp\cellbox+.5\normalbaselineskip}{\makecell{Should be bottom}}
\end{tabular}

\end{document}

Note that the anchor points for all cells still remain in the middle (vertically) of each cell.

3

A work-around consists in adding empty lines. I took the opportunity to add some padding to the cells with \makegapedcells:

\documentclass{article}
\usepackage{makecell}

\begin{document}

\begin{center}
\setcellgapes{3pt}\makegapedcells
\begin{tabular}{ l | l l l}
 & Leistung & Stunden & Preis \\
\hline
1. Webdesign & \makecell[l]{asdads asd asd ada dadadas dasdas d
 \\ asdada sdasdasdasd \\ sdads asd asd ada dadadas dasdas d
 \\ asdada sdasdasdasd \\ sdads asd asd ada dadadas dasdas
 d \\ asdada sdasdasdasd}
 & \makecell{Should be top\\\\\\\\\\\\} & \makecell{\\\\\\\\\\6Should be bottom} \\
\end{tabular}
\end{center}

\end{document} 

enter image description here

2

Look at the following example, the two alignment labels [t], [b] already work but only if you add more lines of text and the alignment is relative to the first column. This is because you didn't provide a label to makecell in the big cell in second column, so it is vertically centered by default.

\documentclass{article}
\usepackage{makecell}    

\begin{document}
\begin{center}
\begin{tabular}{  l | l l l}
 & Leistung & Stunden & Preis \\
\hline
1. Webdesign &  \makecell[l]{asdads asd asd ada dadadas dasdas d
 \\ asdada sdasdasdasd \\ sdads asd asd ada dadadas dasdas d
 \\ asdada sdasdasdasd \\ sdads asd asd ada dadadas dasdas 
 d \\ asdada sdasdasdasd} 
 & \makecell[t]{Should be top\\and is really top} & \makecell[b]{6Should be bottom\\and is still bottom}  \\
\end{tabular}
\end{center}

\end{document}

enter image description here

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.