1

I have this longtable table, where I want to locate two multicolumns after each other. When I compile with the second multicolumn commented out, everything is fine (pic 1). But with two consecutive multicolumns the width of the table is completely changed (pic 2). What's happening?

My question might be a duplicate of Multicolumn width in longtable, but I don't see how the solution can be used in my problem...

MWE:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{fouriernc}
\usepackage{tabularx,booktabs,parskip}
\usepackage[text={9in,6in},showframe,landscape]{geometry}
\usepackage{setspace,url,multirow,longtable,array}
\usepackage{enumitem}
\setlist{nolistsep}
\renewcommand\labelitemi{--}
\newcolumntype{P}[1]{>{\raggedright}p{\dimexpr#1\textwidth-2\tabcolsep}}

\begin{document}
\begin{longtable}{P{0.05} P{0.05} P{0.3} P{0.3} P{0.15} P{0.15}}
    \toprule
    \multicolumn{2}{l}{Tema: } & \multicolumn{4}{l}{Geometri} \tabularnewline
    % \multicolumn{2}{l}{Kompetansemål i K06: } & \multicolumn{4}{l}{Some text} \tabularnewline
    \midrule
    Uke & Time & Læringsmål for timen & Arbeidsmetoder & Uformell vurdering & Kjerneord/ begreper \tabularnewline 
    \midrule
    \endfirsthead
    %
    \multicolumn{3}{c}%
    {{\bfseries \tablename\ \thetable{} -- fortsatt fra forrige side}} \tabularnewline
    \midrule Uke & Time & Læringsmål for timen & Arbeidsmetoder & Uformell vurdering & Kjerneord/begreper \tabularnewline \midrule
    \endhead
    %
    \midrule \multicolumn{3}{|r|}{{Fortsetter på neste side}} \tabularnewline \midrule
    \endfoot
    %
    \bottomrule
    \endlastfoot
    46 & 1 & Some stuff & Some more stuff & Utsjekk. & Katet, hypotenus, kvadrat
    \tabularnewline
    \bottomrule
\end{longtable}
\end{document}

Producing

enter image description here

While without commenting out the second multicolumn the table is way outside the page borders:

enter image description here

1 Answer 1

2

Your multicolumn switched the column type to l which forces the first two columns to be wide enough to take the text without line breaking, so they are wider than specified by your P{0.05} and the table overflows. You need to make the first two columns wider, or allow the text to break eg

    \multicolumn{2}{P{.1}}{Komp\-etan\-semål i K06: } & \multicolumn{4}{l}{Some text} \tabularnewline
1
  • Aha, thanks. Didn't catch that one.
    – Holene
    Nov 8, 2013 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .