表格中的多列

表格中的多列

请问有什么问题multicolumn?有 8 个单元格,不是吗?

\documentclass[12pt, a4paper]{report}

\usepackage[textwidth=145mm, textheight=247mm, nohead, showframe]{geometry}
\let\openright=\clearpage
%\usepackage[a-2u]{pdfx}
\usepackage[czech]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, graphicx}
\usepackage{array}
\usepackage{caption}
\usepackage[output-decimal-marker={,}]{siunitx}
\NewDocumentCommand{\anote}{}{\makebox[0pt][l]{$^*$}}

\usepackage[usenames]{xcolor}


\usepackage{amsfonts}

\usepackage{makecell,threeparttable}
\usepackage{amssymb}
\usepackage{dcolumn}
%\setlength\heavyrulewidth{0.25ex}
\usepackage{multirow, tabularx}
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\usepackage{ragged2e}
\newcolumntype{d}[1]{D{.}{,}{#1}}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcommand\stack[1]{\multicolumn{1}{c}{\shortstack{#1}}}
\newcommand{\angstrom}{\mbox{\normalfont\AA}}

\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\newcommand\mytab[1]{%
   \bgroup%
   \setlength\extrarowheight{0pt}%
   \smash{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}%
   \egroup}
%%% code block to handle the OP's follow-up question -- see
%%% https://tex.stackexchange.com/a/112002/5001 for the source
\usepackage{regexpatch}
\makeatletter
% Change the `-` delimiter to an active character
\xpatchparametertext\@cline{-}{\cA-}{}{}
\makeatother
\hfuzz=99pt

\begin{document}

    \begin{table}[ht!]
    \scriptsize
    \renewcommand{\cellset}{\renewcommand{\arraystretch}{0.75}\scriptsize}
    \setlength\extrarowheight{2pt}
    \setlength\tabcolsep{2pt} % default: 6pt
    \begin{threeparttable}
    \begin{tabularx}{\textwidth}{C|*{2}{C} >{\hsize=0.7\hsize}C >{\hsize=1.3\hsize}Cc*{3}{C}}
    \Xhline{0.8pt}\noalign{\vskip 0.4ex}\Xhline{0.8pt}%
    \multirowcell{4}{Veličina} & \multicolumn{2}{c|}{[1]} & \multicolumn{2}{c|}{[2]} & \multicolumn{1}{c|}{[3]} & \multicolumn{3}{c|}{[4]} \\[0.4ex]
    \cline{2-9}
    \multicolumn{1}{c|}{} &\multicolumn{2}{c|}{\multirowcell{1.5}{PHOEBE fotometrie a RV}}
     &\multicolumn{1}{c|}{\multirowcell{3}{POWR\\ analýza}} & %
    \multicolumn{1}{c|}{\multirowcell{3}{Řešení\\ světelných\\ křivek a RV}} &
   \multicolumn{1}{c|}{ \multirowcell{3}{CFF }}&\multicolumn{1}{c|}{ \multirowcell{3}{Model\\malá\\ hmotnost}} & \multicolumn{1}{c|}{\multirowcell{3}{Model\\ střední\\ hmotnost}} & \multicolumn{1}{c|}{\multirowcell{3}{Model\\ velká\\ hmotnost}} \\[1ex]
    \cline{2-3}
    & \multicolumn{1}{c|}{\multirowcell{1.5}{Řešení II}} & \multicolumn{1}{c|}{\multirowcell{1.5}{Řešení III}} & \multicolumn{1}{c|}{}& \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} \\ [1.5ex]

    \Xhline{0.8pt}%
    &&&&&&\\[-10pt]

\makecell{$P$ \\ (dny)}&    \multicolumn{8}{c}{5,732436}&   &   &   &   &   &   &   \\

  \Xhline{0.8pt}%
     \end{tabularx}
    \end{document}

答案1

您的代码中有几个错误。

  1. 你开启了\begin{table}[ht!]但你没有结束它!
  2. \end{threeparttable}丢失了。我将其添加到了正确的位置...
  3. 表中的最后一行应该用\makecell{$P$ \\ (dny)}& \multicolumn{8}{c}{5,732436} \\

请参阅以下更正后的代码

\documentclass[12pt, a4paper]{report}

\usepackage[textwidth=145mm, textheight=247mm, nohead, showframe]{geometry}
\let\openright=\clearpage
%\usepackage[a-2u]{pdfx}
\usepackage[czech]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, graphicx}
\usepackage{array}
\usepackage{caption}
\usepackage[output-decimal-marker={,}]{siunitx}
\NewDocumentCommand{\anote}{}{\makebox[0pt][l]{$^*$}}

\usepackage[usenames]{xcolor}


\usepackage{amsfonts}

\usepackage{makecell,threeparttable}
\usepackage{amssymb}
\usepackage{dcolumn}
%\setlength\heavyrulewidth{0.25ex}
\usepackage{multirow, tabularx}
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\usepackage{ragged2e}
\newcolumntype{d}[1]{D{.}{,}{#1}}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcommand\stack[1]{\multicolumn{1}{c}{\shortstack{#1}}}
\newcommand{\angstrom}{\mbox{\normalfont\AA}}

\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\newcommand\mytab[1]{%
   \bgroup%
   \setlength\extrarowheight{0pt}%
   \smash{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}%
   \egroup}
%%% code block to handle the OP's follow-up question -- see
%%% https://tex.stackexchange.com/a/112002/5001 for the source
\usepackage{regexpatch}
\makeatletter
% Change the `-` delimiter to an active character
\xpatchparametertext\@cline{-}{\cA-}{}{}
\makeatother
\hfuzz=99pt

\begin{document}

%\begin{table}[ht!] % <=================================================
\scriptsize
\renewcommand{\cellset}{\renewcommand{\arraystretch}{0.75}\scriptsize}
    \setlength\extrarowheight{2pt}
    \setlength\tabcolsep{2pt} % default: 6pt
    \begin{threeparttable}
    \begin{tabularx}{\textwidth}{C|*{2}{C} >{\hsize=0.7\hsize}C >{\hsize=1.3\hsize}Cc*{3}{C}}
    \Xhline{0.8pt}\noalign{\vskip 0.4ex}\Xhline{0.8pt}%
    \multirowcell{4}{Veličina} & \multicolumn{2}{c|}{[1]} & \multicolumn{2}{c|}{[2]} & \multicolumn{1}{c|}{[3]} & \multicolumn{3}{c|}{[4]} \\[0.4ex]
    \cline{2-9}
    \multicolumn{1}{c|}{} &\multicolumn{2}{c|}{\multirowcell{1.5}{PHOEBE fotometrie a RV}}
     &\multicolumn{1}{c|}{\multirowcell{3}{POWR\\ analýza}} & %
    \multicolumn{1}{c|}{\multirowcell{3}{Řešení\\ světelných\\ křivek a RV}} &
   \multicolumn{1}{c|}{ \multirowcell{3}{CFF }}&\multicolumn{1}{c|}{ \multirowcell{3}{Model\\malá\\ hmotnost}} & \multicolumn{1}{c|}{\multirowcell{3}{Model\\ střední\\ hmotnost}} & \multicolumn{1}{c|}{\multirowcell{3}{Model\\ velká\\ hmotnost}} \\[1ex]
    \cline{2-3}
    & \multicolumn{1}{c|}{\multirowcell{1.5}{Řešení II}} & \multicolumn{1}{c|}{\multirowcell{1.5}{Řešení III}} & \multicolumn{1}{c|}{}& \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} \\ [1.5ex]

    \Xhline{0.8pt}%
    &&&&&&\\[-10pt]

%\makecell{$P$ \\ (dny)}&    \multicolumn{8}{c}{5,732436}&   &   &   &   &   &   &   \\
\makecell{$P$ \\ (dny)}&    \multicolumn{8}{c}{5,732436}   \\ % <=======

  \Xhline{0.8pt}%

\end{tabularx}
  \end{threeparttable} % <==============================================
\end{document}

结果:

在此处输入图片描述

相关内容