Longtable com cabeçalho multicoluna e problemas de quebra de linha em multirow

Longtable com cabeçalho multicoluna e problemas de quebra de linha em multirow

Eu gostaria de criar esta tabela:

insira a descrição da imagem aqui

O código para isso está na segunda tabela. (Obrigado ao Bernard por isso!) Infelizmente recebo dois erros por causa dessas duas tabelas.

A primeira é: Algo está errado – talvez um item faltando. \end{tabularx}

O segundo é: \omit mal colocado. \end{tabularx}

O Código é:

\documentclass[a4paper, ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[showframe]{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{ragged2e}
\usepackage{tabularx, multirow, caption, makecell, hhline}      
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{ltablex}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TABLE 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{table}[!htbp]
\centering
\setlength\tabcolsep{3pt}
\setlist[itemize]{wide=0pt, labelsep=2pt, leftmargin=*, nosep, before 
=\mbox{}\vspace*{-.7\baselineskip}, after=\vspace*{-.8\baselineskip}}
\caption{\label{tab:Gestaltungsbereiche}Gestaltungsbereiche}
%
\begin{tabularx}{\textwidth}{|c|*{3}{>{\RaggedRight}X|}}
\hhline{~|---|}
\multicolumn{1}{r|}{} & \multicolumn{3}{c|}
{\cellcolor{Gainsboro}Gestaltungsbereiche} \\
\hhline{~|---|}
\rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}} &% 
\multicolumn{1}{>{\centering}X}{\centering Betriebsmittel\newline \centering 
(B)}
\makecell{Betriebsmittel\\ (B)} & \makecell{Organisation\\ (O)} & 
\makecell{Raum- und \\Gebäudetechnik \\ (R)}\\
\hline
\multirow{11}{*}[-1ex]{\rotatebox{90}{Fabrikobjekte}}
& \begin{itemize}
    \item Fertigungseinrichtungen
    \item Montageeinrichtungen
    \item Logistikeinrichtungen
    \item Qualitätseinrichtungen
    \item Informations- und 
    \newline Kommunikations\-einrichtungen
    \item Ver- und Entsorgungs\-einrichtungen
    \item Übergeordnete Systeme
    \item Mobiliar
\end{itemize} %
& \begin{itemize}
    \item Unternehmensstrategie
    \item Logistikkonzept
    \item Prozessgestaltung
    \item Aufbauorganisations\-gestaltung
    \item Arbeitsorganisation
    \item Qualitätssicherungs\-konzept
\end{itemize} %
& \begin{itemize}
    \item Grundstück
    \item Bau\-konstruktion
    \item Technische Anlagen
    \item Außenanlagen
    \item Ausstattung
    \item Konzepte
\end{itemize} \\%
\hline
\end{tabularx}%
\end{table}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TABLE 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newpage
\keepXColumns
\setlength{\extrarowheight}{3pt}
\begin{tabularx}{\textwidth}{|c|*{2}{>{\RaggedRight}X|}p{9cm}|}
\caption{Betriebsmittel: Fabrikobjekte}
\label{tab:addlabel}%\\
\hhline{~|---|}
\rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}}&
\multicolumn{1}{>{\centering\columncolor{Gainsboro}[\tabcolsep][1em]}X}
{\centering Fabrikobjekte 1.Ordnung}&
\multicolumn{2}{c|}{Fabrikobjekte 2.Ordnung}
\\
\hhline{----}
\endfirsthead
\hhline{~|---|}
\rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}}&
\multicolumn{1}{>{\centering\columncolor{Gainsboro}[\tabcolsep][1em]}X}
{\centering Fabrikobjekte 1.Ordnung}&
\multicolumn{2}{c|}{Fabrikobjekte 2.Ordnung}
 \\
\hhline{----}
\endhead
\multirow{45}{*}[-1ex]{\rotatebox{90}{Gestaltungsfeld: Betriebsmittel}}  
%%%
& \multirow{11}{*}{Fertigungseinrichtung} & \multirow{5}{*}{Maschine} &
Gestell \\
& & & Antriebe\\
& & & Kinematisches System \\
& & & Steuerungs-/ Mess-/Regel- \&
Diagnosesysteme \\
& & & Hilfssysteme / Peripherie \\[0.4ex]
\cline{3-4}
& &
\multirow{3}{*}{Vorrichtung / Hilfmittel} &
Vorrichtungs- \& Spannsysteme \\
& & & Werkstückflusssystem \\
& & & Steuerung \\[0.4ex]
\cline{3-4}& & Werkzeuge & \\[0.4ex]
\cline{2-4}& \multirow{9}{*}{Montageeinrichtungen} & {\multirow{5}{*}
{Montagegrundplatz}} & {Gestell} \\
& & & Antriebe\\
& & & Kinematisches System \\
& & & Steuerungs-/ Mess-/Regel- \& Diagnosesysteme \\
& & & Hilfssysteme / Peripherie \\[0.4ex]
\cline{3-4}
& & \multirow{3}{*}{Vorrichtung / Hilfmittel} & {Vorrichtungs- \& 
Spannsysteme} \\
& & &{Werkstückflusssystem} \\
& & & {Steuerung} \\[0.4ex]
\cline{3-4}& & {Werkzeuge} &  \\[0.4ex]
\cline{2-4}& \multirow{25}{*}{Logistikeinrichtungen} & {\multirow{6}{*}
{Transporteinrichtungen}} & {Gestell} \\
& & & Transportvorrichtung\\
& & & Antriebe\\
& & & Kinematisches System \\
& & & Steuerung \\
& & & Hilfssysteme / Peripherie \\[0.4ex]
\cline{3-4}
& & {\multirow{6}{*}{Handhabungseinrichtungen}} & {Gestell} \\
& & & Handhabungsvorrichtung\\
& & & Antriebe\\
& & & Kinematisches System \\
& & & Steuerung \\
& & & Hilfssysteme / Peripherie \\[0.4ex]
\cline{3-4}

\end{tabularx}%
\end{document}

Agradeço cada comentário.

Meu resultado atual para a segunda tabela é este:

insira a descrição da imagem aqui

Responder1

\centeringnão é necessário para a longtable: ele é centralizado automaticamente por padrão. Você não precisa inserir um ambiente tabularx em uma tabela longa para dizer que ele se espalhará pelas páginas. Você simplesmente precisa carregar um pacote que adicione a funcionalidade (e a sintaxe) de longtableto tabularx. Eu sugiro usar ltablex.

A sintaxe é a do longtable: você coloca o \captiondentrotabularx, antes da declaração para first table head(essas declarações terminam com `\endfirsthead).

Então sugiro adicionar os cabeçalhos das colunas com as declarações dos cabeçalhos dos cabeçalhos seguintes (que terminam com \endhead).

Removi todos os \multicolumn{1}{l|}da última coluna, o que evita quebra de linha e gera transbordamento para a margem.

Então aqui está o código que proponho:

\documentclass[a4paper, ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[showframe]{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{ragged2e}
\usepackage{multirow, caption, makecell, hhline}
\usepackage{graphicx}
\usepackage{ltablex}
\keepXColumns
\begin{document}
%\begin{longtable}
%\centering
%\caption{Betriebsmittel: Fabrikobjekte}
\setlength{\extrarowheight}{3pt}
\begin{tabularx}{\textwidth}{|c|*{3}{>{\RaggedRight}X|}}
\caption{Betriebsmittel: Fabrikobjekte}
  \label{tab:addlabel}%\\
    \hhline{~|---|}
     \rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}}&
    \multicolumn{1}{>{\centering\columncolor{Gainsboro}[\tabcolsep][1em]}X}{\centering Fabrikobjekte 1.Ordnung}&
    \multicolumn{2}{c|}{Fabrikobjekte 2.Ordnung}
    \\
    \hhline{----}
\endfirsthead
    \hhline{~|---|}
     \rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}}&
    \multicolumn{1}{>{\centering\columncolor{Gainsboro}[\tabcolsep][1em]}X}{\centering Fabrikobjekte 1.Ordnung}&
    \multicolumn{2}{c|}{Fabrikobjekte 2.Ordnung}
    \\
    \hhline{----}
\endhead
    \multirow{12}{*}[-1ex]{\rotatebox{90}{Gestaltungsfeld: Betriebsmittel}}
     %%%

     & \multirow{11}{*}{Fertigungseinrichtung} & \multirow{5}{*}{Maschine} &
     Gestell \\
     & & & Antriebe\\
     & & & Kinematisches System \\
     & & & Steuerungs-/ Mess-/Regel- \&
     Diagnosesysteme \\
     & & & Hilfssysteme / Peripherie \\[0.4ex]
     \cline{3-4}
     & &
     \multirow{3}[2]{*}{Vorrichtung / Hilfmittel} &
     Vorrichtungs- \& Spannsysteme \\
     & & & Werkstückflusssystem \\
     & & & Steuerung \\[0.4ex]
     \cline{3-4}& & Werkzeuge & \\[0.4ex]
     \cline{2-4}\\
     %%%
    \end{tabularx}%

    \end{document} 

insira a descrição da imagem aqui

Adicionado:

Este código compila bem com três tabelas. Observe que a terceira tabela é um código mais curto para obter a segunda tabela. Eu mudei o número usado em multirow: você deve pegar o número total delinhasnas linhas a célula multilinha deve se espalhar, e não o número delinhase possivelmente adicionar um argumento opcional corretivo para o posicionamento vertical do conteúdo.

Por outro lado, o carregamento ltablextorna todos tabularxos ambientes um arquivo longtable. Aqui eles estão centralizados, não flutuam (não aninhem table) e a legenda deve ser inseridadentroo ambiente.

\documentclass[a4paper, ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{ragged2e}
\usepackage{multirow, caption, makecell, hhline}
\usepackage{ltablex}%{tabularx}%
\usepackage{graphicx}
\usepackage{enumitem}

\newcommand\mypar{ \par\hangindent=1.5em\hangafter=1}

\begin{document}

\sffamily\captionsetup{font=sf}

\setlength\tabcolsep{3pt}
\setlist[itemize]{wide=0pt, labelsep=2pt, leftmargin=*, nosep, before
  =\mbox{}\vspace*{-.7\baselineskip}, after=\vspace*{-.8\baselineskip}}
\keepXColumns
%
\begin{tabularx}{\textwidth}{|c|*{3}{>{\RaggedRight\arraybackslash}X|}}
  \caption{\label{tab:Gestaltungsbereiche}Gestaltungsbereiche} \\
  \hhline{~|---|}
  \multicolumn{1}{r|}{} & \multicolumn{3}{c|}
  {\cellcolor{Gainsboro}Gestaltungsbereiche} \\
  \hhline{~|---|}
  \rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}} & %
  \makecell{Betriebsmittel \\ (B)} & \makecell{Organisation\\ (O)} &
  \makecell{Raum- und \\Gebäudetechnik \\ (R)}\\
  \hline
  \endfirsthead
  \multirow{11}{*}[-1ex]{\,\rotatebox{90}{Fabrikobjekte}\,}
                                                              &
  \begin{itemize}
    \item Fertigungseinrichtungen
    \item Montageeinrichtungen
    \item Logistikeinrichtungen
    \item Qualitätseinrichtungen
    \item Informations- und
          Kommunikations\-einrichtungen
    \item Ver- und Entsorgungs\-einrichtungen
    \item Übergeordnete Systeme
    \item Mobiliar
  \end{itemize} %
                                                              & \begin{itemize}
    \item Unternehmensstrategie
    \item Logistikkonzept
    \item Prozessgestaltung
    \item Aufbauorganisations\-gestaltung
    \item Arbeitsorganisation
    \item Qualitätssicherungs\-konzept
  \end{itemize} %
                                                              & \begin{itemize}
    \item Grundstück
    \item Bau\-konstruktion
    \item Technische Anlagen
    \item Außenanlagen
    \item Ausstattung
    \item Konzepte
  \end{itemize}
  \\%
  \hline
\end{tabularx}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TABLE 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newpage
\setlength{\extrarowheight}{2pt}
\begin{tabularx}{\textwidth}{|c|*{2}{>{\RaggedRight}X|}>{\RaggedRight}p{4.8cm}|}
  \caption{Betriebsmittel: Fabrikobjekte}
  \label{tab:addlabel} \\
  \hhline{~|---|}
  \multicolumn{1}{r|}{\cellcolor{white}} &
  \cellcolor{Gainsboro}\centering Fabrikobjekte 1.Ordnung &
  \multicolumn{2}{c|}{\cellcolor{Gainsboro}Fabrikobjekte 2.Ordnung}
  \\
  \hhline{----}
  \endfirsthead
  \hhline{~|---|}
  \rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}} &
  \multicolumn{1}{>{\centering\columncolor{Gainsboro}[\tabcolsep][1em]}X}
  {\centering Fabrikobjekte 1.Ordnung} &
  \multicolumn{2}{c|}{Fabrikobjekte 2.Ordnung}
  \\
  \hhline{----}
  \endhead
  \hhline{----}
  \endfoot
  \multirow{32}{*}{\,\rotatebox{90}{Gestaltungsfeld: Betriebsmittel}\,}
  %
                                                              & \multirow{11}{=}{Fertigungseinrichtung} & \multirow{6}{*}{Maschine} &
  Gestell \\
                                                              & & & Antriebe \\
                                                              & & & Kinematisches System \\
                                                              & & & Steuerungs-/ Mess-/Regel- \& \par\quad Diagnosesysteme \\
                                                              & & & Hilfssysteme / Peripherie \\[0.4ex]
  \cline{3-4}
                                                              & &
  \multirow{3}{=}{Vorrichtung / Hilfmittel} &
  Vorrichtungs- \& Spannsysteme \\
                                                              & & & Werkstückflusssystem \\
                                                              & & & Steuerung \\[0.4ex]
  \cline{3-4} & & Werkzeuge & \\[0.4ex]
  \cline{2-4} & \multirow{11}{=}[-2pt]{Montageeinrichtungen} &
  \multirow{6}{=}{Montagegrundplatz} & Gestell \\
                                                              & & & Antriebe \\
                                                              & & & Kinematisches System \\
                                                              & & & Steuerungs-/ Mess-/Regel- \&\par\quad Diagnosesysteme \\
                                                              & & & Hilfssysteme / Peripherie \\[0.4ex]
  \cline{3-4}
                                                              & & \multirow{3}{=}{Vorrichtung / Hilfmittel} & {Vorrichtungs- \& Spannsysteme} \\
                                                              & & & Werkstückflusssystem \\
                                                              & & & Steuerung \\[0.4ex]
  \cline{3-4} & & {Werkzeuge} & \\[0.4ex]
  \cline{2-4} & \multirow{12}{=}{Logistikeinrichtungen} &
  \multirow{6}{=}{Transporteinrichtungen} & Gestell \\
                                                              & & & Transportvorrichtung \\
                                                              & & & Antriebe \\
                                                              & & & Kinematisches System \\
                                                              & & & Steuerung \\
                                                              & & & Hilfssysteme / Peripherie \\[0.4ex]
  \cline{3-4}
                                                              & & \multirow{6}{=}{Handhabungseinrichtungen} & Gestell \\
                                                              & & & Handhabungsvorrichtung \\
                                                              & & & Antriebe \\
                                                              & & & Kinematisches System \\
                                                              & & & Steuerung \\
                                                              & & & Hilfssysteme / Peripherie \\[0.4ex]
\end{tabularx}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TABLE 2 bis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newpage
\setlength{\extrarowheight}{3pt}
\begin{tabularx}{\textwidth}{|c|*{2}{>{\RaggedRight}X|}>{\RaggedRight\everypar{\hangindent=1.5em\hangafter=1}}p{4.8cm}|}
  \caption{Betriebsmittel: Fabrikobjekte}
  \label{tab:addlabel} \\
  \hhline{~|---|}
  \multicolumn{1}{r|}{\cellcolor{white}} &
  \cellcolor{Gainsboro}\centering Fabrikobjekte 1.Ordnung &
  \multicolumn{2}{c|}{\cellcolor{Gainsboro}Fabrikobjekte 2.Ordnung}
  \\
  \hhline{----}
  \endfirsthead
  \hhline{~|---|}
  \rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}} &
  \multicolumn{1}{>{\centering\columncolor{Gainsboro}[\tabcolsep][1em]}X}
  {\centering Fabrikobjekte 1.Ordnung} &
  \multicolumn{2}{c|}{Fabrikobjekte 2.Ordnung}
  \\
  \hhline{----}
  \endhead
  \hhline{----}
  \endfoot
  \multirow{27}{*}{\,\rotatebox{90}{Gestaltungsfeld: Betriebsmittel}\,}
  %
                                                              & \multirow{11}{=}{Fertigungseinrichtung} & \multirow{6}{=}{Maschine}
                                                              & Gestell \par Antriebe \par Kinematisches System \par Steuerungs-/ Mess-/Regel- \& Diagnosesysteme \par Hilfssysteme / Peripherie \\[0.4ex]
  \cline{3-4}
                                                              & & \multirow{3}{=}{Vorrichtung / Hilfmittel} &
  Vorrichtungs- \& Spannsysteme \par Werkstückflusssystem \par Steuerung \\[0.4ex]
  \cline{3-4} & & Werkzeuge & \\[0.4ex]
  \cline{2-4} & \multirow{11}{=}[-2pt]{Montageeinrichtungen} & \multirow{6}{=}{Montagegrundplatz} %
                                                              & Gestell \par Antriebe \par Kinematisches System \par Steuerungs-/ Mess-/Regel- \& Diagnosesysteme \par Hilfssysteme / Peripherie \\[0.4ex]
  \cline{3-4}
                                                              & & \multirow{3}{=}{Vorrichtung / Hilfmittel} &
  Vorrichtungs- \& Spannsysteme \par Werkstückflusssystem \par Steuerung \\[0.4ex]
  \cline{3-4} & & {Werkzeuge} & \\[0.4ex]
  \cline{2-4} & \multirow{12}{=}{Logistikeinrichtungen} & \multirow{6}{*}{Transporteinrichtungen}
                                                              & Gestell \par Transportvorrichtung \par Antriebe \par Kinematisches System \par Steuerung \par Hilfssysteme / Peripherie \\[0.4ex]
  \cline{3-4}
                                                              & & \multirow{6}{=}{Handhabungseinrichtungen}
                                                              & Gestell \par Handhabungsvorrichtung \par Antriebe \par Kinematisches System \par Steuerung \par Hilfssysteme / Peripherie \\[0.4ex]
\end{tabularx}%

\end{document} 

insira a descrição da imagem aqui insira a descrição da imagem aqui insira a descrição da imagem aqui

Responder2

Se você receber um erro do TeX, você não deve realmente olhar para o resultado da composição.

O erro aqui é

! Package array Error:  Illegal pream-token (\centering): `c' used.

Porque após o argumento opcional o primeiro token é \centeringquando, como a maioria dos ambientes de array, longtableestá procurando uma especificação de coluna.

O argumento opcional só pode ser [c], [l]ou [r]então [!htbp]é simplesmente ignorado (nenhum erro é fornecido principalmente por razões históricas), então removi esse argumento opcional.

então mudando para

\begin{longtable}{ccc}

produz saída sem erros, mas a legenda está à esquerda de tabularxquando você omitiu \\para encerrar a longtablelinha.

Paro neste ponto porque não está claro o que você deseja. Atualmente, a longtabletabela inteira possui apenas uma única célula em uma única coluna que consiste em um aninhado, tabularxse esse for o caso real, você não precisa longtablede nada e poderia apenas ter o tabularx interior de um table?

\documentclass[a4paper, ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[showframe]{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{ragged2e} 
\usepackage{tabularx, multirow, caption, makecell, hhline}
\usepackage{graphicx}
\usepackage{longtable}

\begin{document}
\begin{longtable}{ccc}
\caption{Betriebsmittel: Fabrikobjekte}\\
\begin{tabularx}{\textwidth}{|c|*{3}{>{\RaggedRight}X|}}
\hhline{~|---|}
\rowcolor{Gainsboro} \multicolumn{1}{r|}{\cellcolor{white}} & 
\multicolumn{1}{>{\centering}X}{\centering Fabrikobjekte 1.Ordnung}&
\multicolumn{2}{>{\centering}X}{\centering Fabrikobjekte 2.Ordnung}
\\
\hline
\multirow{11}{*}[-1ex]{\rotatebox{90}{Gestaltungsfeld: Betriebsmittel}}
 %%%

 & \multirow{9}{*}{Fertigungseinrichtung} & \multirow{5}{*}{Maschine} & 
 \multicolumn{1}{l|}{Gestell} \\
 &       &       & \multicolumn{1}{l|}{Antriebe} \\
 &       &       & \multicolumn{1}{l|}{Kinematisches System} \\
 &       &       & \multicolumn{1}{l|}{Steuerungs-/ Mess-/Regel- \& 
 Diagnosesysteme} \\
 &       &       & \multicolumn{1}{l|}{Hilfssysteme / Peripherie} \\
 \cline{3-4}          
 &       & 
 \multirow{3}[2]{*}{Vorrichtung / Hilfmittel} & 
 \multicolumn{1}{l|}{Vorrichtungs- \& Spannsysteme} \\
 &       &       & \multicolumn{1}{l|}{Werkstückflusssystem} \\
 &       &       & \multicolumn{1}{l|}{Steuerung} \\
 \cline{3-4}&       & Werkzeuge &  \\
 \cline{2-4}\\

 %%%
\end{tabularx}%
\label{tab:addlabel}%
\end{longtable}%    
\end{document} 

Responder3

você tentou inserir linhas vazias após as múltiplas colunas? Eu tive o mesmo problema e percebi que bastava adicionar linhas vazias para conseguir espaço suficiente para a outra.

 &       &       & \multicolumn{1}{l|}{Werkstückflusssystem} \\
    &       &       & \\
    &       &       & \multicolumn{1}{l|}{Steuerung} \\
    &       &       & \\

informação relacionada