Problema y MWE

Problema y MWE

Problema y MWE

Me gustaría aumentar el ancho de la siguiente longtblrtabla tanto como el ancho máximo de página permitido, que debería ser, supongo, tan ancho como el texto, es decir, desde el margen izquierdo hasta el margen derecho de la página. En otras palabras, me gustaría que la siguiente tabla fuera tan ancha como el texto, desde el margen izquierdo hasta el margen derecho.

Sin embargo, tendría una limitación. Me gustaría mantener el mismo ancho de las siguientes columnas.

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

excepto por la sexta columna (la llamada Feature 2), que ahora es 6cmancha. Por tanto, la idea es trabajar sólo con el ancho de la 6ª columna.

Básicamente, me gustaría ampliar/aumentar el ancho de la sexta columna de tal manera que todo el ancho de la tabla alcance el ancho máximo de página permitido.

¿Existe alguna forma automática de hacerlo, o debería aumentar el ancho de la sexta columna siempre que, a simple vista, vea que los bordes izquierdo y derecho de mi tabla estén alineados con todo el texto del documento?

¡Espero que esto quede suficientemente claro! Aquí sigue mi MWE y la figura correspondiente:

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

ingrese la descripción de la imagen aquí

Respuesta1

  • Puede aumentar el ancho de la sexta columna solo reduciendo el ancho de la otra columna. En su caso, reduciría el ancho de la quinta y última columna, para la sexta columna usaría Xel tipo de columna, cuyo ancho es \textwidth: suma de los anchos de las columnas restantes.
  • Para un ancho mayor de la sexta columna, puede reducirlo colsep.
  • Como puede ver, en la sexta columna centré tblrla tabla insertada.
\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}

ingrese la descripción de la imagen aquí

Las líneas grises indican el diseño de la página.

información relacionada