問題とMWE

問題とMWE

問題とMWE

次の表の幅を、最大ページ幅まで広げたいと思いますlongtblr。これは、おそらく、テキストと同じ幅、つまりページの左余白から右余白までの幅になるはずです。言い換えると、次の表を、左余白から右余白まで、テキストと同じ幅にしたいのです。

しかし、制約があります。次の列の幅を同じにしておきたいのです。

colspec={m{0.9cm} m{0.1cm} m{0.6cm} m{1cm} m{3cm} m{6cm} m{1.5cm}},

ただし、6 番目の列 ( と呼ばれる列Feature 2) は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 番目の列の幅を増やすには、他の列の幅を減らす必要があります。あなたの場合、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}

ここに画像の説明を入力してください

灰色の線はページレイアウトを示します。

関連情報