3

Consider this example:

\documentclass{article}                                                                                                                                                                                       
\begin{document}
\begin{tabular}{ p{0.1\textwidth}l }
  gdgd asfsdf akku  & 5  \\
\end{tabular}
\end{document}

enter image description here

How can I centre the contents of cell 01 vertically?

5

Here are three different possible solutions:

\documentclass{article}
\usepackage{array}    % Only needed for the first example.
\usepackage{multirow} % Only needed for the third example.
\begin{document}

Using the vertically centered m type column: 

\begin{tabular}{ m{0.1\textwidth}l }
  gdgd asfsdf akku  & 5  \\
\end{tabular}

\bigskip

Using three different rows for the text in the first column:

\begin{tabular}{ p{0.1\textwidth}l }
  gdgd\\
  asfsdf   & 5\\
  akku   \\
\end{tabular}

\bigskip

Using multirow:

\begin{tabular}{ p{0.1\textwidth}l }
  gdgd asfsdf akku  & \multirow{3}{*}{5}  \\
\end{tabular}
\end{document}

enter image description here

4

You can use multirow with a single cell, but you have to count the number of lines in this cell, on order to vertically centre its contents. Note that you can use decimal numbers to fine-tune the placement.

Alternatively, use the m{...} column type for the left column (requires loading array):

\documentclass{article}
\usepackage{array}
\usepackage{multirow}

\begin{document}

\begin{tabular}{m{0.1\textwidth}l }
  gdgd asfsdf akku & 5 \\
\end{tabular}
\qquad
\begin{tabular}{p{0.1\textwidth}l }
  gdgd asfsdf akku & \multirow{3}{*}{5}\\
\end{tabular}

\end{document} 

enter image description here

1

A possible solution would be using the multirow package (But it requires you to split cell on the left into three cells and putting the text of the right cell into a multirow-cell that spans over three rows). A working example would be:

\documentclass{article}                                                                     \usepackage{multirow}                                                                                                
\begin{document}
\begin{tabular}{ p{0.1\textwidth}l }
  gdgd & \multirow{3}{*}{5} \\ 
  asfsdf \\ 
  akku \\
\end{tabular}
\end{document}

Result

A little explanation on the code:

gdgd & \multirow{3}{*}{5} \\

Inserts gdgd as the first entry of the first row and an multirow-cell that spans over three rows (the first parameter) inherits the width of the original column (second parameter set as *) and contains the text "5" (last parameter). \\ indicates the linebreak

asfsdf \\ 

Inserts asfsdf into the first entry of the second line. Another entry in this line is not necessary because of the multirow-cell above.

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.