Tabularx 具有多列和多行

Tabularx 具有多列和多行

我使用以下代码来创建表

\usepackage{multirow}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{L}{>{\raggedright\arraybackslash}X} % for ragged-right material
\newcolumntype{C}{>{\centering\arraybackslash}X}   % for centered material


\begin{document}

\begin{table}

      \begin{tabularx}{\textwidth}{LLLL}
         \hline\noalign{\smallskip}
       \multicolumn{2}{l}{Processes Types} & \multirow{2}{*}{}{Data movement Description} & \multirow{2}{*}{}{Data measurement Description}\\\cmidrule(lr){1-2}
       Functional Process & Service process \\
      \noalign{\smallskip}\hline\noalign{\smallskip}
       Data1 & Data2 & Data3 & Data4\\
       \hline
       \end{tabularx}

     \end{table}
\end{document}

如何才能消除图 1 中指定的空间,使其看起来像图 2 一样?

图1

图 2

谢谢。

答案1

粗暴的黑客是添加

\multirow{2}{*}{}{Data measurement Description}\\[-2.5em]\cmidrule(lr){1-2}

笔记\\[-2.5em]

\documentclass{article}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{L}{>{\raggedright\arraybackslash}X} % for ragged-right material
\newcolumntype{C}{>{\centering\arraybackslash}X}   % for centered material


\begin{document}

\begin{table}

      \begin{tabularx}{\textwidth}{LLLL}
         \hline\noalign{\smallskip}
       \multicolumn{2}{l}{Processes Types} & \multirow{2}{*}{}{Data movement Description} & \multirow{2}{*}{}{Data measurement Description}\\[-2.5em]\cmidrule(lr){1-2}
       Functional Process & Service process & & \\
      \noalign{\smallskip}\hline\noalign{\smallskip}
       Data1 & Data2 & Data3 & Data4\\
       \hline
       \end{tabularx}

     \end{table}
\end{document}

在此处输入图片描述

答案2

解决方案使用makecell;诀窍是\multirow{n}{…}插入最后的行,带有负 n。我还\addlinespace从包中添加了一些booktabs,这样桌子看起来就不那么紧凑了。

\documentclass[a4paper,11pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{fourier}

    \usepackage{geometry} 
    \usepackage[sups]{heuristica}
    \usepackage{array, multirow, tabularx, booktabs}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{L}{>{\raggedright\arraybackslash}X} % for ragged-right material
\newcolumntype{C}{>{\centering\arraybackslash}X} % for centered material

\usepackage{makecell}
\begin{document}

\begin{table}
\setlength\tabcolsep{4pt}
  \begin{tabularx}{\textwidth}{@{}*{4}{C}}
     \toprule\addlinespace
   \multicolumn{2}{>{\hsize=2\hsize}C}{Processes Types} & & \\
   \addlinespace\cmidrule(lr){1-2}\addlinespace
           \makecell{Functional\\ Process} & \makecell{Service\\ process} &\multirowcell{-2}[0.5ex]{Data movement\\ Description} & \multirowcell{-2}[0.5ex]{Data measurement\\ Description} \\
   \addlinespace\midrule\addlinespace%
   Data1 & Data2 & Data3 & Data4\\
    \addlinespace \bottomrule
   \end{tabularx}

 \end{table}

\end{document}  

在此处输入图片描述

相关内容