# Center wide longtable (not tabular or tabularx)

I have a long and wide table that does fit on A4 format, but is too wide for the text margins. I want that table to be able to spread over multiple pages, but I also want it to be centered on the page. So centered in a way that it overlaps both sides of the text margins equally.

Well, I've seen a solution a lot, but only for tabular or tabularx this seems to work. For a longtable I get errors. In this post on a less active blog I explained my problem as well and I found similar answers on this website:

Could anybody tell me what I'm doing wrong or what I don't get? Is there a solution to my non-centered too wide longtable?

-
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. – Werner Oct 25 '11 at 22:26
Would you be able to provide a sample of a very long table that is too wide and long to fit on your page? That is, create a minimal (perhaps non-working) example for other to work with? – Werner Oct 25 '11 at 22:26
I did in the comment on the post below, however I was not able to initiate code markup unfortunately... I could not do what was told here: <tex.stackexchange.com/editing-help#bare-urls>; – Adriaan Oct 26 '11 at 8:28

The key is to suitably set the lengths \LTleft and \LTright that longtable uses for the horizontal placement of the table.

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begingroup
\setlength{\LTleft}{-20cm plus -1fill}
\setlength{\LTright}{\LTleft}
\begin{longtable}{|*{13}{p{1cm}}|}
01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 10 & 11 & 12 & 13 \\
01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 10 & 11 & 12 & 13 \\
01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 10 & 11 & 12 & 13 \\
01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 10 & 11 & 12 & 13 \\
\end{longtable}
\endgroup
\lipsum[2]
\end{document}

-
Thanks for the answer, I was not familiar with this syntaxis. This fixes the problem indeed, but I already thought that temporarely changing the margins would do the trick. (although I did not post it, sorry) The option to draw a box around it and not necessary reset the margins seemed more polite to me. But let me change my question, why does the MWE below not work? And why does it when one changes longtable to tabular? – Adriaan Oct 26 '11 at 8:19
\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}  – Adriaan Oct 26 '11 at 8:19
I said it fixes the problem, but it does not totally, the table is not centered exactly as you can see in your MWE. Where did you get the -20cm plus -1fill? – Adriaan Oct 26 '11 at 9:04
It is centered; of course with a non symmetric text block, such as with book, the longtable will stick out the same length on both sides of the text block. The 20cm are just a wide enough length (2*20 = 40 > 21) and -1fill` is to fill up the non covered part of the 20cm. – egreg Oct 26 '11 at 12:11
Ok, you are right, compared to the text it is centered now, let's rephrase my question then... ;) How do I center the table compared to the page? So the same amount of white space on both sides between the side of the paper and the table. – Adriaan Oct 26 '11 at 20:05