5

I'm trying to make a longtabu that is wider than the textwidth at a certain moment. I've tried different things always ending up with a different problem:

First possibility: If I use the adjustwidth environment the longtabu does not align correctly. The left margin stays fixed and the right margin gets out of the page. This in contrast, if I do the exact same thing to make a tabu(instead of longtabu), it works perfectly. I think using the adjustwidth is the best way to go, but I can't manage to get it working.

Second possibility: I've found a solution using the fullwidth package. That package does the trick, but using endhead and endfirsthead is completely ignored. So it does not help me either, because I need that.

Final possibility: Using the geometry package does the trick, but that package adds a pagebreak when I start using it, I can't have that. It has to be directly under some text, which has a narrower textwidth.

Cheers.

I add a little example:

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{chngpage}
\usepackage{lipsum}
\usepackage{tabu}

\begin{document}
\section{This is the original textwidth.}
\lipsum[1]

\section{This is the width I need for my longtabu}
\begin{adjustwidth}{-1in}{-1in}
    \begin{tabu} to \linewidth {*{13}{|X[l]} |}
    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{tabu}
\end{adjustwidth}

\section{This is what happens}
\begin{adjustwidth}{-1in}{-1in}
    \begin{longtabu} to \linewidth {*{13}{|X[l]} |}
    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{longtabu}
\end{adjustwidth}

\end{document}
  • The document preamble? Or where? – user34491 Aug 19 '13 at 12:57
  • It does not work properly. If I do the following only the first column is properly moved: \begin{longtabu} to \linewidth { @{\hspace{-5cm}} *{13}{X[l]}} Acutally it is clear that it just interprets the hspace for the first column, not for the table itself. – user34491 Aug 19 '13 at 13:20
  • still same problem as with the adjustwidth environment, left margin stays fixed – user34491 Aug 19 '13 at 13:51
  • 1
    questions should always have a complete small example document that shows the problem, please add one to your question, it makes things a lot easier to test/discus! – David Carlisle Aug 19 '13 at 13:54
  • I added an example to the main question. – user34491 Aug 19 '13 at 14:11
3

longtable lets you set the left and right margins but unfortunately the tabu wrapper around longtable always passes in an optional argument which sets the margins to 0pt or \fill depending on the lcr alignment.

So for longtabu as well as setting the margins to -1in you need to patch tabu not to default c alignment (which would reset them back to \fill).

enter image description here

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{chngpage}
\usepackage{lipsum}
\usepackage{tabu}

\begin{document}
\section{This is the original textwidth.}
\lipsum[1]

\setlength\LTleft{-1in}
\setlength\LTright{-1in}
\section{This is the width I need for my longtabu}


\noindent\kern-1in X \dotfill X\kern-1in\mbox{}



\makeatletter
\g@addto@macro\tabu@setup{\def\tabu@aligndefault{x}}
\makeatother

    \begin{longtabu} to \dimexpr\linewidth+0in\relax  {*{13}{|X[l]} |}
    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{longtabu}


\end{document}

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.