
문제 및 MWE
허용되는 최대 페이지 너비만큼 다음 표의 너비를 늘리고 싶습니다 longtblr
. 즉, 페이지의 왼쪽 여백에서 오른쪽 여백까지 텍스트만큼 넓어야 합니다. 즉, 다음 표를 왼쪽 여백부터 오른쪽 여백까지 텍스트만큼 넓게 만들고 싶습니다.
그러나 제약이 있을 것입니다. 다음 열의 너비를 동일하게 유지하고 싶습니다
colspec={m{0.9cm} m{0.1cm} m{0.6cm} m{1cm} m{3cm} m{6cm} m{1.5cm}},
Feature 2
이제 넓어진 6번째 열( 라고 불리는 열)을 제외하고 6cm
. 따라서 6번째 열의 너비로만 작업하는 것이 아이디어입니다.
기본적으로 전체 테이블 너비가 허용되는 최대 페이지 너비에 도달하도록 6번째 열의 너비를 확장/증가시키고 싶습니다.
자동으로 그렇게 할 수 있는 방법이 있습니까? 아니면 눈으로 볼 때 테이블의 왼쪽 및 오른쪽 테두리가 전체 문서 텍스트와 정렬되어 있는 것을 볼 수 있는 한 6번째 열의 너비를 늘려야 합니까?
이것이 충분히 명확하기를 바랍니다! 내 MWE와 해당 수치는 다음과 같습니다.
\documentclass[twocolumn]{article}
% Some packages
\usepackage[margin=2cm]{geometry}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{light-gray}{HTML}{FFFFFF}
\definecolor{light-blue}{HTML}{EBF5FB}
\usepackage{tabularray}
\usepackage{url}
% Other packages
\usepackage{lipsum}
\usepackage{tabulary,longtable,afterpage}
\usepackage{booktabs}
\makeatletter
\newcommand{\aftertwo}[1]{\afterpage{\if@firstcolumn #1
\else\afterpage{#1}\fi}}
\makeatother
% Start of the document
\begin{document}
% Some text
\lipsum[1-8]
% A "longtblr" table
\aftertwo{
\onecolumn
\begin{longtblr}[
caption = {This is a caption.},
]{
colspec={m{0.9cm} m{0.1cm} m{0.6cm} m{1cm} m{3cm} m{6cm} m{1.5cm}},
cells={font=\small},
row{1}={font=\itshape\small},
row{2,5-7}={bg=light-blue},
row{3-4}={bg=light-gray},
column{6}={preto={\minipage{6cm}}, appto={\endminipage}},
hlines
}
& Day
& Month
& Hours
& Feature 1
& Feature 2
& Feature 3\\
%-------------------------------------------------
Friday
& 5
& June
&
& This is a quite short text.
& This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times.
\begin{tblr}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tblr}
& Short text
\\
%-------------------------------------------------
\SetCell[r=2]{l} Saturday
& \SetCell[r=2]{l} 6
& \SetCell[r=2]{l} June
& 14 -- 21
& B\textsubscript{1}
&
& B\textsubscript{3}
\\
&
&
&
& C\textsubscript{1}
& C\textsubscript{2}
& C\textsubscript{3}
\\
% -------------------------------------------------
\SetCell[r=3]{l} Sunday
& \SetCell[r=3]{l} 7
& \SetCell[r=3]{l} June
& 08 -- 10
& D\textsubscript{1}
& D\textsubscript{2}
& D\textsubscript{3}
\\
&
&
& 10 -- 17
& E\textsubscript{1}
&
& E\textsubscript{3}
\\
&
&
&
& F\textsubscript{1}
& F\textsubscript{2}
& F\textsubscript{3}
\\
% -------------------------------------------------
\end{longtblr}
\twocolumn
}
% End of the document
\end{document}
답변1
- 다른 열의 너비를 줄여서만 6번째 열의 너비를 늘릴 수 있습니다. 귀하의 경우 zje 5번째와 마지막 열의 너비를 줄이고 6번째 열의 경우
X
열 유형을 사용합니다. 너비는\textwidth
나머지 열 너비의 합계입니다. - 6번째 열의 너비가 더 커지면 줄이세요
colsep
. - 보시다시피, 6번째 열에
tblr
테이블을 삽입했습니다.
\documentclass[twocolumn]{article}
\usepackage[showframe,
margin=2cm]{geometry}
\usepackage{lipsum} %for dummy text
\usepackage[dvipsnames,table]{xcolor}
\definecolor{light-gray}{HTML}{FFFFFF}
\definecolor{light-blue}{HTML}{EBF5FB}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{tabulary,longtable,afterpage}
\usepackage{url}
\makeatletter
\newcommand{\aftertwo}[1]{\afterpage{\if@firstcolumn #1
\else\afterpage{#1}\fi}}
\makeatother
\begin{document}
% Some text
\lipsum[1-8]
% A "longtblr" table
\aftertwo{
\onecolumn
\begin{longtblr}[
caption = {This is a caption.},
]{colspec = {llll Q[l,22mm] X[h, j] Q[l, 3em] },
colsep=4pt,
column{6}={preto={\minipage{\linewidth}}, appto={\endminipage}},
cells={font=\small},
row{1}={font=\itshape\small},
row{2,5-7}={bg=light-blue},
row{3-4}={bg=light-gray},
hlines
}
& Day
& Month
& Hours
& Feature 1
& Feature 2
& Feature 3\\
%-------------------------------------------------
Friday
& 5
& June
&
& This is a quite short text.
& This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times.
\centering
\begin{tblr}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tblr}
& Short text \\
%-------------------------------------------------
\SetCell[r=2]{l} Saturday
& \SetCell[r=2]{l} 6
& \SetCell[r=2]{l} June
& 14 -- 21
& B\textsubscript{1}
&
& B\textsubscript{3}
\\
&
&
&
& C\textsubscript{1}
& C\textsubscript{2}
& C\textsubscript{3} \\
%--------------------------------------------------
\SetCell[r=3]{l} Sunday
& \SetCell[r=3]{l} 7
& \SetCell[r=3]{l} June
& 08 -- 10
& D\textsubscript{1}
& D\textsubscript{2}
& D\textsubscript{3}
\\
&
&
& 10 -- 17
& E\textsubscript{1}
&
& E\textsubscript{3}
\\
&
&
&
& F\textsubscript{1}
& F\textsubscript{2}
& F\textsubscript{3} \\
% -------------------------------------------------
\end{longtblr}
\twocolumn
}
% End of the document
\end{document}
회색 선은 페이지 레이아웃을 나타냅니다.