我有一张longtable
表格,我想在multicolumn
其中放置两个 s。当我编译时将第二个multicolumn
注释掉,一切都很好(图 1)。但是如果有两个连续的multicolumn
s,表格的宽度就会完全改变(图 2)。发生了什么?
我的问题可能是长表中的多列宽度,但我不知道该解决方案如何应用于我的问题......
梅威瑟:
\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}
制作
尽管没有注释掉第二行,但multicolumn
表格却超出了页面边界:
答案1
您的多列切换了列类型l
,强制前两列足够宽以容纳文本而不会换行,因此它们比您指定的要宽,P{0.05}
表格溢出。您需要使前两列更宽,或者允许文本换行,例如
\multicolumn{2}{P{.1}}{Komp\-etan\-semål i K06: } & \multicolumn{4}{l}{Some text} \tabularnewline