
여러 개의 긴 텍스트가 포함된 표가 있는데 페이지 너비에 맞출 수 없습니다. 최적의 열 너비 세트(텍스트 너비에 따른 시행착오 포함)를 알아냈지만 내용을 넣으면 테이블이 깨지거나 작동하지 않습니다.
나중에 해결 방법을 만들었습니다. 더 이상 병합된 행이 아니고 끔찍해 보입니다. 그리고 종이에 테이블을 사용할 것이기 때문에 사용할 수 없습니다. 내 해결 방법:
\documentclass{article}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{libertine}
\usepackage[verbose=true,letterpaper]{geometry}
\AtBeginDocument{
\newgeometry{
textheight=9in,
textwidth=6.5in,
top=1in,
headheight=14pt,
headsep=25pt,
footskip=30pt
}
}
\begin{document}
\begin{longtable}[h]{p{1.2cm}p{3.8cm}p{1.8cm}p{2cm}p{1.8cm}p{3.5cm}}
\caption{Sample table}
\label{table:sample} \\
\hline
\textbf{Col 1} & \textbf{Col 2} & \textbf{Slightly loooooooong name} & \textbf{Col 4} & \textbf{Col 5} & \textbf{Col 6} \\ \hline
\endfirsthead
\multicolumn{5}{c}{{\bfseries Table \thetable\ continued from previous page}} \\
\hline
\textbf{Col 1} & \textbf{Col 2} & \textbf{Slightly looooong name} & \textbf{Col 4} & \textbf{Col 5} & \textbf{Col 6} \\ \hline
\endhead
\\ \hline
\multicolumn{5}{r}{{Continued on next page}} \\ \hline
\endfoot
\\ \hline
\endlastfoot
\multirow{2}{*}{lorem ipsum} & voluptatem accusantium doloremque laudantium & 111,111 & 222,222 & 333,333 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \\
& voluptatem accusantium doloremque laudantium & 444,444 & 555,555 & 666,666 \\
\end{longtable}
\end{document}
예를 들어 첨부된 이미지를 보면 열 너비를 지정했는데도 넘치고 있는 것을 볼 수 있습니다. 내가 필요한 것은1열그리고6열이 두 열의 높이, 바람직하게는 내가 지정한 열 너비로 조정해야 합니다.
를 사용해보니 \makecell
3줄의 조합처럼 보였습니다. 다른 방법(너비가 있는 여러 행 등)을 시도했지만 문제를 해결할 수 없습니다.
답변1
내가 잘 이해했다면 다음이 필요합니다.
\documentclass{article}
\usepackage{libertine}
\usepackage[verbose=true,letterpaper]{geometry}
\AtBeginDocument{
\newgeometry{
textheight=9in,
textwidth=6.5in,
top=1in,
headheight=14pt,
headsep=25pt,
footskip=30pt
}
}
\usepackage{tabularray}
\DefTblrTemplate{conthead-text}{normal}{\bfseries Table \thetable\ continued from previous page}
\begin{document}
\begin{longtblr}[
caption={Sample table},
label={table:sample},
]{
colspec={Q[l,1.2cm]Q[l,3.8cm]Q[l,1.8cm]Q[l,2cm]Q[l,1.8cm]Q[l,3.5cm]},
hline{1,2,Z}={solid},
row{1}={font=\bfseries},
rowhead=1,
}
Col 1 & Col 2 & Slightly loooooooong name & Col 4 & Col 5 & Col 6 \\
\SetCell[r=2]{l} lorem ipsum & voluptatem accusantium doloremque laudantium & 111,111 & 222,222 & 333,333 & \SetCell[r=2]{l} Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \\
& voluptatem accusantium doloremque laudantium & 444,444 & 555,555 & 666,666 \\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
Other & lines & just & to & show & the page break\\
\end{longtblr}
\end{document}
답변2
이 같은?
\multirow
여기서는 유용한 기여가 없으므로 지시문 을 삭제했습니다 .
\documentclass{article}
\usepackage{longtable}
\usepackage{libertine}
\usepackage[verbose=true,letterpaper]{geometry}
\AtBeginDocument{%
\newgeometry{%
textheight=9in, textwidth=6.5in,
top=1in, headheight=14pt, headsep=25pt,
footskip=30pt
}
}
\usepackage{array}
\usepackage{ragged2e} % for '\RaggedRight' macro
\usepackage{booktabs} % for well-spaced horizontal rules
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\hyphenation{looooooo-ong loooo-ong} % choose something sensible
\begin{document}
\begin{longtable}{@{} P{1.2cm} P{3.9cm} *{3}{P{1.8cm}} P{3.9cm} @{}}
%% headers and footers
\caption{Sample table} \label{table:sample} \\
\toprule
\textbf{Col 1} & \textbf{Col 2} &
\textbf{Slightly loooooooong name} &
\textbf{Col 4} & \textbf{Col 5} &
\textbf{Col 6} \\
\midrule
\endfirsthead
\multicolumn{6}{@{}l}{Table \thetable, continued from preceding page} \\
\addlinespace
\toprule
\textbf{Col 1} & \textbf{Col 2} &
\textbf{Slightly looooong name} &
\textbf{Col 4} & \textbf{Col 5} &
\textbf{Col 6} \\
\midrule
\endhead
\midrule
\multicolumn{6}{r@{}}{\footnotesize Continued on next page} \\
\endfoot
\bottomrule
\endlastfoot
%% body of longtable
lorem ipsum &
voluptatem accusantium doloremque laudantium &
111,111 & 222,222 & 333,333 &
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \\
\addlinespace
&
voluptatem accusantium doloremque laudantium &
444,444 & 555,555 & 666,666 \\
\end{longtable}
\end{document}