mais problemas com longtable e multirow

mais problemas com longtable e multirow

na minha pergunta anterior, houve algumas soluções alternativas que resolveram meu problema imediato. No entanto, tenho a sensação de que esses dois pacotes não funcionam bem juntos. Adicionar mais uma coluna e ter múltiplas linhas em diferentes conjuntos de linhas faz com que as soluções alternativas não funcionem.

Aqui está o código:

\documentclass{article}

\usepackage{longtable}
\usepackage {multirow}
\usepackage{lipsum}

\begin{document}

\begin{center}
\begin{longtable}{p{.15\textwidth} p{.15\textwidth} p{0.32\textwidth} p{0.32\textwidth}}
\hline 
1 & 1.1 & \multirow{2}{.32\textwidth} {\lipsum[1] } & some text \\ \cline{4-4}
 & 1.2 & & \multirow{2}{.32\textwidth}{\lipsum[2]} \\ \cline{2-3}  
& 1.3 & some other text  & \\ \hline
 2 & 2.1 & some more text & \lipsum[3] \\ \hline 
 \end{longtable}
\end{center}

\end{document}

E o resultado claramente não é bom. Qualquer ajuda para encontrar uma solução genérica para este problema seria muito apreciada.

saída do código anterior

Responder1

A resposta à sua pergunta anterior (quase a mesma) resolve o seu problema. Caso contrário, sua pergunta não está clara.

Adoção de @sveinungresponder:

\documentclass{article}
\usepackage{makecell, longtable}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
    \begin{longtable}{|p{\dimexpr0.07\textwidth-2\tabcolsep-1.25\arrayrulewidth}
                      |p{\dimexpr0.07\textwidth-2\tabcolsep-1.25\arrayrulewidth}
                      |p{\dimexpr0.43\textwidth-2\tabcolsep-1.25\arrayrulewidth}
                      |p{\dimexpr0.43\textwidth-2\tabcolsep-1.25\arrayrulewidth}
                      |}
    \hline
1   & 1.1   & \lipsum[1]        & some text     \\ \cline{2-4}
    & 1.2   &                   & \lipsum[2]    \\ \cline{2-4}
    & 1.3   & some other text   &               \\ 
    \hline
2   & 2.1   & some more text    & \lipsum[3]    \\ 
    \hline
    \end{longtable}
\end{document}

Observação: \multirow[<number of rows>{...}{cell's contents}não determina sua altura com o número de linhas (que contém). Ele abrange um determinado número de linhas na coluna adjacente. Se a altura deles for menor que a altura da multirowcélula, seu conteúdo se espalhará pelas células adjacentes, como você observa na sua pergunta.

Por favor, leia a documentação do pacote como @ebcontrol sugere em seu comentário.

Editar:A largura da coluna agora está corrigida e a largura da longtableé exatamente \textwidth.

Responder2

ObservaçãoEu atualizei o código por exemplo 2

Eu uso textos fictícios mais curtos para que os exemplos sejam mais legíveis. Veja os dois exemplos anexos e diga-nos como eles se desviam do que você tenta alcançar. Em particular, o exemplo 2 exige trabalho manual:

Exemplo 1

insira a descrição da imagem aqui

\documentclass{article}

\usepackage{longtable, booktabs, array}
\usepackage{lipsum}

\newcolumntype{O}{p{\dimexpr(0.15\linewidth-1.5\tabcolsep)}}
\newcolumntype{Q}{p{\dimexpr(0.35\linewidth-1.5\tabcolsep)}}


%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\newcommand{\mytexti}{This is a dummy text, however I have an issue using multirow and longtable. The content in the multirow cell is very large, and it goes well beyond the limit of the "non-multirowed" rows. LaTeX ignores that and starts the following row just behind those rows, therefore overwriting the content.}

\newcommand{\mytextii}{This is a shorter dummy text, LaTeX ignores me!}

\begin{document}

\begin{longtable}{@{}OOQQ@{}}
   \toprule\addlinespace[1ex]
1 & 1.1 & \mytexti         & some text \\ \cmidrule{4-4}
  & 1.2 &                  & \mytextii \\ \cmidrule{3-3}  
  & 1.3 & some other text  &           \\ \bottomrule \addlinespace[1ex]
2 & 2.1 & some more text   & \mytexti  \\ \bottomrule 
\end{longtable} 

\end{document}

Exemplo 2

insira a descrição da imagem aqui

\documentclass{article}

\usepackage{longtable, booktabs, array, multirow, bigstrut}
\usepackage{lipsum}

    \newcolumntype{O}{p{\dimexpr(0.15\linewidth-1.5\tabcolsep)}}
    \newcolumntype{Q}{p{\dimexpr(0.35\linewidth-1.5\tabcolsep)}}


%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\newcommand{\mytexti}{This is a dummy text, however I have an issue using multirow and longtable. The content in the multirow cell is very large, and it goes well beyond the limit of the "non-multirowed" rows. LaTeX ignores that and starts the following row just behind those rows, therefore overwriting the content.}

\newcommand{\mytextii}{This is a shorter dummy text, LaTeX ignores me!}


\begin{document}

\begin{longtable}{@{}OOQQ@{}}
   \toprule\addlinespace[1ex]
1   &                                   & \mytexti          & some text\strut   \hrule  \\ 
    & \multirow[t]{-14}{=}{1.1\\ 1.2}   & some other text   & \multirow[t]{-12.9}{=}{\mytextii}     \\ \cmidrule{3-3}
    & 1.3   & some other text   &                                                               \\
\bottomrule \addlinespace[1ex]  
 2  & 2.1   & some more text    & \mytexti                                                      \\ \bottomrule 

 \end{longtable} 

\end{document}

informação relacionada