Cómo ajustar la tabla larga al ancho de línea

Cómo ajustar la tabla larga al ancho de línea

Estoy trabajando con una tesis clásica y tengo un documento general bastante complicado, por lo que no puedo publicar un MWE (lo siento, soy bastante nuevo en LaTeX). Sin embargo, estoy publicando algunos paquetes que creo que pueden estar relacionados con la mesa. Mi problema: estoy usando una tabla larga que se distribuye automáticamente en varias páginas. Todo funciona bien excepto que excede el ancho del texto (a pesar de definir las columnas usando \linewidth).

¿Podría ayudarme a identificar qué estoy haciendo mal o cómo puedo hacer coincidir el ancho de la tabla con el ancho de línea?

¡Gracias una tonelada!

\usepackage{calc, longtable, ltablex, booktabs,array, caption, enumitem}
\keepXColumns
\newcolumntype{x}[1]{>{\raggedright}p{#1}}

\begin{spacing}{.7}
\footnotesize
\begin{longtable}{x{0.35\textwidth} x{0.25\textwidth} x{0.4\textwidth}}
    \caption{Example table}\label{tab:example}  \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
    \tabularnewline
    \midrule
    \endfirsthead
    %%%%
    \caption{Example table (cont.)}  \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
    \tabularnewline
    \midrule
    \endhead
    %%%%
    \midrule[\heavyrulewidth]
    \multicolumn{3}{r}{\footnotesize\itshape Continue on the next page}
    \endfoot
    %%%%
    \bottomrule
    \endlastfoot
    %%%%

        Content & Content & Content   \tabularnewline
        Content & Content & Content   \tabularnewline

\end{longtable}
\end{spacing}

Respuesta1

Tienes

\begin{longtable}
      {x{0.35\textwidth} x{0.25\textwidth} x{0.4\textwidth}}

pero cada columna tiene \tabcolsepun espacio (predeterminado de 6 puntos) a cada lado, por lo que tendrá 36 puntos de ancho.

intentar

\begin{longtable}
      {@{}x{0.35\textwidth} x{\dimexpr 0.25\textwidth - 24pt\relax} x{0.4\textwidth}@{}}

entonces quitas el relleno de los lados @{}y guardas 24 puntos en la columna del medio (o, por supuesto, puedes distribuirlo de manera diferente y eliminar algo de cada columna)

Respuesta2

Usaría el xltabularentorno (el paquete se carga ltablex, pero ahorra la molestia de tener que agregarlo keepXColumns), con las especificaciones >{\hsize)xx\hsize para tener columnas de diferentes anchos):

\documentclass{report}
\usepackage{classicthesis}
\usepackage{array, setspace}
\usepackage{calc, longtable,xltabular, booktabs, array, caption, enumitem}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}

\begin{document}

\mbox{}
\begin{spacing}{.7}
\footnotesize
\begin{xltabular}{\linewidth}{>{\hsize=1.05\hsize}X >{\hsize=0.75\hsize}X >{\hsize=1.20\hsize\arraybackslash}X}
    \caption{Example table}\label{tab:example} \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}} \\
    \midrule
    \endfirsthead
    %%%%
    \caption{Example table (cont.)} \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}} \\
    \midrule
    \endhead
    %%%%
    \midrule[\heavyrulewidth]
    \multicolumn{3}{r}{\footnotesize\itshape Continue on the next page}
    \endfoot
    %%%%
    \bottomrule
    \endlastfoot
    %%%%
        Content & Content & Content \\
        Content & Content & Content
\end{xltabular}
\end{spacing}

\end{document} 

ingrese la descripción de la imagen aquí

información relacionada