3

I have this table

\documentclass[a4paper]{scrartcl}
\usepackage{longtable}
\begin{document}

\begin{longtable}{c|p{6cm}p{4cm}p{4cm}}
\hline
Blub & Bla & Blip & Blop \\
Blub & Bla & Blip & Blop \\
\hline
\end{longtable}
\end{document}

Now, for whatever reason, I would like to center ONE cell of the second column. How would I achieve that?

6

Since you're using a paragraph column type (with fixed length), you can issue \centering inside the cell to centre it:

\documentclass[a4paper]{scrartcl}
\usepackage{longtable}
\begin{document}

\begin{longtable}{c|p{6cm}p{4cm}p{4cm}}
\hline
Blub & Bla & Blip & Blop \\
Blub & \centering Bla & Blip & Blop \\
\hline
\end{longtable}
\end{document}

Other column types (like l and r) requires a different approach.

  • Wow... I bet I tried that before... oh well. Thanks! – cherrung Jul 13 '12 at 21:22
  • 2
    With the caveat that if the last column is involved, either one says \centering\arraybackslash or ends the cell by \tabularnewline. – egreg Jul 13 '12 at 21:35
  • I had to add a \par to close the centering to make this work for me. – rogueleaderr May 6 '16 at 0:58
1

Another approach -- which works regardless of whether the column is specified via l, r, or p monikers -- is to use the \multicolumn command. This command takes three arguments: set 1 as the first argument (the number of columns), c as the second argument (to center it, in this case), and "Bla" (or whatever it may be...) as the third argument:

\multicolumn{1}{c}{Bla}

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.