I am trying to center a side longtable using \makebox[\textwidth]{ it worked for a normal table.

\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\noindent\makebox[\textwidth]{
    \begin{longtable}
        {>{\centering\arraybackslash}m{0.55\textwidth} >{\centering\arraybackslash}m{0.55\textwidth}}
        \lipsum[2] & \lipsum[3] \
  \end{longtable}
}

\lipsum[4]
\end{document}

I use sharelatex and get the error Missing \endgroup inserted..

edit: I saw How to fit landscape multi-page table to textwidth but LTcapwidth didn't help

  • as you see this does not work at all for longtable, but it is not a good way to center a tabular either, better to use \centering (longtables are by default, so there is nothing to do in that case) – David Carlisle Jul 11 at 11:51
  • your title asks about making a table full width but the text of your question asks about centreing, which do you want to do? If something is full width then centering is a no-op, longtables are centred by default, the posted answers show how to make it full width. – David Carlisle Jul 11 at 11:53
up vote 2 down vote accepted

longtable has its own method for this:

\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\begingroup % localize the following settings
\setlength{\LTleft}{0pt minus 1000pt}
\setlength{\LTright}{0pt minus 1000pt}

\begin{longtable}{
  >{\centering\arraybackslash}m{0.55\textwidth}
  >{\centering\arraybackslash}m{0.55\textwidth}
}
\lipsum[2] & \lipsum[3]
\end{longtable}
\endgroup

\lipsum[4]
\end{document}

enter image description here

With xltabular instead of longtable:

\documentclass[a4paper]{article}
\usepackage{xltabular}
\usepackage{lipsum}

\begin{document}
\lipsum[1]

\begingroup % localize the following settings
\setlength\LTleft{0pt minus 1000pt}
\setlength\LTright{0pt minus 1000pt}
\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{xltabular}{1.1\linewidth}{>{\centering}X>{\centering}X}
        \lipsum[2] & \lipsum[3]
\end{xltabular}
\endgroup

\lipsum[4]
\end{document}

enter image description here

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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