Configurando a largura da tabela exatamente como a largura da linha

Configurando a largura da tabela exatamente como a largura da linha

Estou tentando criar uma tabela com exatamente a mesma largura do texto ao redor.

Eu esperaria que o comando \resizebox{\linewidth}{!}{..table..}fizesse o trabalho. No entanto, a largura das tabelas ainda é muito pequena.

insira a descrição da imagem aqui

\documentclass{scrartcl} 
\usepackage{graphicx}
\usepackage[table]{xcolor}
\setlength{\parindent}{0pt}

\usepackage[
  top=0.600cm, 
  bottom=0.600cm,
  left=0.600cm, 
  right=0.600cm]
  {geometry}


\begin{document}
bla blub blaaa bla blub blaaabla blub blaaa bla blub blaaa bla blub blaaa bla blub blaaaa
bla blub blaaa bla blub blaaabla blub blaaa bla blub blaaa bla blub blaaa bla blub blaaaa
bla blub blaaa bla blub blaaabla blub blaaa bla blub blaaa bla blub blaaa bla blub blaaaa
bla blub blaaa bla blub blaaabla blub blaaa bla blub blaaa bla blub blaaa bla blub


\resizebox{\linewidth}{!}{
\begin{tabular}{|l|l|l|l|}
  \hline
  test entry & test entry & test entry & test entry \\
  test entry & test entry & test entry & test entry \\
  test entry & test entry & test entry & test entry \\
  \hline
\end{tabular}
}

\end{document}

Responder1

Acho que você tem duas boas escolhas e uma escolha (provavelmente) terrível:

  • Use um tabular*ambiente,

  • Use um tabularxambiente (ou seu primo próximo tabulary)

  • Use o ambiente básico tabulare aumente (ou diminua) usando \resizebox.

Os resultados são os seguintes (a primeira linha horizontal existe apenas para ilustrar a largura do bloco de texto; acorposdas quatro tabelas são idênticas, ou seja, diferem "apenas" em seus layouts):

insira a descrição da imagem aqui

Você pode dizer por que considero o método usado \resizeboxnada menos que terrível?

\documentclass{scrartcl} 
\usepackage{graphicx} % for '\resizebox` macro
\usepackage{tabularx} % for 'tabularx' environment
\setlength{\parindent}{0pt}
\usepackage[margin=0.6cm]{geometry}
\newcommand\TestTable{% define body of test table
  \hline
  test entry & test entry & test entry & test entry \\
  test entry & test entry & test entry & test entry \\
  test entry & test entry & test entry & test entry \\
  \hline}
\begin{document}
\hrule

\subsubsection*{Unscaled}

\begin{tabular}{llll}
\TestTable
\end{tabular}

\subsubsection*{Using \texttt{tabular*}}

\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}lll}
\TestTable
\end{tabular*}

\subsubsection*{Using \texttt{tabularx}}

\begin{tabularx}{\textwidth}{XXXX}
\TestTable
\end{tabularx}

\subsubsection*{Scaled with \texttt{\textbackslash resizebox}}

\resizebox{\linewidth}{!}{%
\begin{tabular}{llll}
\TestTable
\end{tabular}}

\end{document}

informação relacionada