0
\begin{center}
    \begin{longtable}{|>{\centering}m{.2\textwidth}|m{.2\textwidth}|}
    \hline
    \makecell[{{p{.2\textwidth}}}]{this is a test test test test test test\\ a test too} & bear \\\hline
    \end{longtable}
\end{center}

enter image description here The first column is left aligned, but I want to center-align the column. What can I do this?

  • 1
    Why not simply use this is a test test test test test test\\ a test too & bear \\\hline without the makecell command? – leandriis Jan 2 '19 at 10:06
1

I don't know if this is what is needed:

\documentclass[]{article}
\usepackage{longtable,makecell}
\begin{document}
\begin{center}
with makecell
    \begin{longtable}{|c|m{.2\textwidth}|}
    \hline
    \makecell[cm{0.2\textwidth}]{\centering this is a test test test test test test
    \\ a test too} & bear \\\hline
    \end{longtable}
\end{center}

\begin{center}
without makecell
    \begin{longtable}{|>{\centering}m{0.2\textwidth}|m{.2\textwidth}|}
    \hline
  this is a test test test test test test
    \\ a test too & bear \\\hline
    \end{longtable}
\end{center}
\end{document}

The second suggestion is based on @leandriis comment

enter image description here

  • Thanks for your answer! It perfectly solved my problem. – user178717 Jan 3 '19 at 1:14
  • 1
    @user178717 If this does solve you problem please mark the answer as accepted – Hafid Boukhoulda Jan 3 '19 at 12:10

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.