longtable 및 multirow에 대한 더 많은 문제

longtable 및 multirow에 대한 더 많은 문제

이전 질문에는 즉각적인 문제를 해결하는 몇 가지 해결 방법이 있었습니다. 하지만 이 두 패키지가 서로 잘 작동하지 않는 것 같은 느낌이 듭니다. 열을 하나 더 추가하고 여러 행 집합에 여러 행을 사용하면 해결 방법이 작동하지 않습니다.

코드는 다음과 같습니다.

\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}

그리고 그 결과는 분명히 좋지 않습니다. 이 문제에 대한 일반적인 해결책을 찾는 데 도움을 주시면 매우 감사하겠습니다.

이전 코드의 출력

답변1

이전(거의 동일한) 질문에 대한 답변으로 문제가 해결됩니다. 그렇지 않은 경우 귀하의 질문은 명확하지 않습니다.

@sveinung의 채택답변:

\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}

메모: \multirow[<number of rows>{...}{cell's contents}(포함된) 행 수로 높이를 결정하지 않습니다. 인접한 열의 주어진 행 수만큼 확장됩니다. 높이가 셀 높이보다 작으면 multirow질문에서 관찰한 대로 해당 내용이 인접한 셀에 쏟아집니다.

@ebcontrol이 그의 의견에서 제안한 대로 패키지 문서를 읽어 보십시오.

편집하다:이제 열 너비가 수정되었으며 의 너비는 longtable정확히 입니다 \textwidth.

답변2

주의예제 2의 코드를 업데이트했습니다.

예제를 더 쉽게 읽을 수 있도록 더 짧은 더미 텍스트를 사용합니다. 동봉된 두 가지 예를 보고 그것이 달성하려는 목표에서 어떻게 벗어나는지 알려주십시오. 특히 예제 2에서는 수동 작업이 필요합니다.

실시예 1

여기에 이미지 설명을 입력하세요

\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}

실시예 2

여기에 이미지 설명을 입력하세요

\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}

관련 정보