tabularray
다양한 colspan과 rowspan을 사용하여 테이블을 만드는 데 사용하고 있습니다 . 테이블에는 width = \linewidth
및 이 있지만 colspec = {|X[1]|X[1]|X[2]|}
선폭을 초과하고 열 너비 X
요청이 준수되지 않습니다.
테이블이 선폭을 유지하고 내가 지정한 열 너비를 준수하도록 하려면 어떻게 해야 합니까?
최소 작업 예:
\documentclass{article}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{makecell}
\usepackage{tabularray}
\usepackage{pgffor, etoolbox}
% headers and footers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear existing header/footer entries
\fancyhead[C]{\footnotesize test}
\begin{document}
\noindent
\begin{tblr}{
width = \linewidth,
colspec = {|X[1]|X[1]|X[2]|}
}
%\begin{tblr}{|p{0.2\linewidth}|p{0.2\linewidth}|p{0.4\linewidth}|}
\hline
\SetCell[c=3]{c} \textbf{DOCUMENTATION INFORMATION PAGE} & &
\\
\hline
\textbf{1. DATE} \newline date & \textbf{2. DOCUMENT TYPE} \newline document type & \textbf{3. DOCUMENT NUMBER / REV} \newline document number \space document version
\\
\hline
\SetCell[c=2]{l} \textbf{4. Title \newline title } & & \textbf{5. PROJECT CODE} \newline project code
\\
\hline
\SetCell[c=2]{l} \textbf{6. AUTHOR} \newline author & & \textbf{7. CUSTOMER} \newline customer
\\
\hline
\SetCell[c=2,r=2]{l} {
\textbf{8. CONTACT ADDRESS} \\
Lorem \\
Ipsum \\
Dolor \\
Sit \\
Amet
}
&
&
\textbf{9. CONTACT PHONE} \newline telephone number \vspace{0.4em}
\\
\hline
&
&
\textbf{10. CONTACT EMAIL} \newline author email
\\
\hline
\SetCell[c=2]{l} \textbf{11. TELEPHONE NUMBER} \newline telephone number
&
&
\textbf{12. NAME OF RESPONSIBLE PERSON} \newline author
\\
\hline
\end{tblr}
\end{document}
답변1
tabularray
기존 테이블의 구문을 일반 테이블의 구문 과 혼합하지 마세요 . \newline
대신 \\
.
편집하다:`colspec˙을 다음과 같이 변경하면 셀 텍스트 간격이 더 좋아집니다.
colspec = {X[0.9, l,h] X[1.1, l,h] X[2,l,h]},
이전 MWE 버전에서 이를 고려하면 다음과 같습니다.
수정된 MWE는 다음과 같습니다.
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{makecell}
\usepackage{tabularray}
\usepackage{pgffor, etoolbox}
% headers and footers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear existing header/footer entries
\fancyhead[C]{\footnotesize test}
\begin{document}
\noindent%
\begin{tblr}{hlines, vlines,
colspec = {X[0.9, l,h] X[1.1, l,h] X[2,l,h]},
row{1} = {font=\bfseries},
cell{3-Z}{1} = {c=2}{},
vspan=even
}
\SetCell[c=3]{c} DOCUMENTATION INFORMATION PAGE
& & \\
{\textbf{1. DATE}\\ date}
& {\textbf{2. DOCUMENT TYPE}\\ document type}
& {\textbf{3. DOCUMENT NUMBER/REV}\\ document number\\ document version} \\
{\textbf{4. Title\\ title}}
& & {\textbf{5. PROJECT CODE}\\ project code} \\
{\textbf{6. AUTHOR}\\ author}
& & {\textbf{7. CUSTOMER}\\ customer} \\
\SetCell[c=2, r=2]{l} {\textbf{8. CONTACT ADDRESS} \\
Lorem \\
Ipsum \\
Dolor \\
Sit \\
Amet}
& & {\textbf{9. CONTACT PHONE}\\ telephone number} \\
& & {\textbf{10. CONTACT EMAIL}\\ author email} \\
{\textbf{11. TELEPHONE NUMBER}\\ telephone number}
& & {\textbf{12. NAME OF RESPONSIBLE PERSON}\\ author} \\
\end{tblr}
\end{document}
답변2
\\
대신 사용 \newline
하고 {}
관련 셀 내용을 감싸면 문제가 사라집니다. 여기서는 왜 작동하지 않는지 잘 모르겠습니다 \newline
(사실 마지막 줄의 첫 번째 셀에만 버그가 있습니다). 어쨌든, \\
패키지 매뉴얼에서 줄 바꿈을 삽입하라고 지시하는 방법은 다음과 같습니다.
\documentclass{article}
\usepackage{tabularray}
% headers and footers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear existing header/footer entries
\fancyhead[C]{\footnotesize test}
\begin{document}
\noindent
\begin{tblr}{
width = \linewidth,
colspec = {|X[1]|X[1]|X[2]|}
}
%\begin{tblr}{|p{0.2\linewidth}|p{0.2\linewidth}|p{0.4\linewidth}|}
\hline
\SetCell[c=3]{c} \textbf{DOCUMENTATION INFORMATION PAGE} & &
\\
\hline
{ \textbf{1. DATE} \\ date } &
{ \textbf{2. DOCUMENT TYPE} \\ document type } &
{ \textbf{3. DOCUMENT NUMBER / REV} \\ document number \space document version }
\\
\hline
\SetCell[c=2]{l}
{ \textbf{4. Title} \\ title } & &
{ \textbf{5. PROJECT CODE} \\ project code }
\\
\hline
\SetCell[c=2]{l}
{ \textbf{6. AUTHOR} \\ author } & &
{ \textbf{7. CUSTOMER} \\ customer }
\\
\hline
\SetCell[c=2,r=2]{l}
{
\textbf{8. CONTACT ADDRESS} \\
Lorem \\
Ipsum \\
Dolor \\
Sit \\
Amet
}
&
&
{ \textbf{9. CONTACT PHONE} \\ telephone number } \vspace{0.4em}
\\
\hline
&
&
{ \textbf{10. CONTACT EMAIL} \\ author email }
\\
\hline
\SetCell[c=2]{l}
{ \textbf{11. TELEPHONE NUMBER} \\ telephone number }
&
&
{ \textbf{12. NAME OF RESPONSIBLE PERSON} \\ author }
\\
\hline
\end{tblr}
\end{document}