Problema e MWE

Problema e MWE

Problema e MWE

Eu gostaria de aumentar a largura da longtblrtabela a seguir tanto quanto a largura máxima da página permitida, que deveria ser - eu acho - tão larga quanto o texto, ou seja, da margem esquerda até a margem direita da página. Em outras palavras, gostaria de deixar a tabela a seguir tão larga quanto o texto, da margem esquerda para a margem direita.

No entanto, eu teria uma restrição. Eu gostaria de manter as mesmas larguras das colunas seguintes

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

exceto a 6ª coluna (aquela chamada Feature 2), que agora é 6cmlarga. Portanto, a ideia é trabalhar apenas com a largura da 6ª coluna.

Basicamente, gostaria de estender/aumentar a largura da 6ª coluna de forma que toda a largura da tabela atinja a largura máxima de página permitida.

Existe alguma maneira automática de fazer isso ou devo aumentar a largura da 6ª coluna, desde que, a olho nu, veja que as bordas esquerda e direita da minha tabela estão alinhadas com todo o texto do documento?

Espero que isso esteja suficientemente claro! Aqui segue meu MWE e a figura correspondente:

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

insira a descrição da imagem aqui

Responder1

  • Você pode aumentar a largura da 6ª coluna apenas reduzindo a largura da outra coluna. No seu caso eu reduziria a largura da 5ª e última coluna, para a 6ª coluna eu usaria Xo tipo de coluna, cuja largura é \textwidth- soma das larguras das colunas restantes.
  • Para largura maior da 6ª coluna, você pode reduzir colsep.
  • Como você pode ver, na 6ª coluna centralizei tblra tabela inserida -
\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}

insira a descrição da imagem aqui

As linhas cinza indicam o layout da página.

informação relacionada