
Ao fazer tabularx
é necessário fornecer a largura da mesa. Para a tabela mais externa, pode-se usar \textwidth
.
Ao fazer uma ou mais tabelas internas dentro de tabelas externas, as tabelas internas também precisam de uma largura, que neste caso será a largura da coluna da tabela externa que esta tabela interna passou a ser dentro. É difícil acompanhar o contexto e fornecer manualmente valores codificados.
Não consigo descobrir como dizer ao LaTeX para usar toda a largura de coluna disponível na tabela externa e deixar o LaTeX fazer o cálculo. Precisa de algo semelhante, X
mas para a largura da tabela em si.
Aqui está um MWE uma tabela dentro da outra.
\documentclass[10pt,notitlepage]{article}%
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
%have to use tabular* for outer table since I can't figure how to use tabularx
\begin{tabular*}{\textwidth}{|p{0.5\textwidth}|p{0.5\textwidth}|}\hline
\begin{tabularx}{0.5\textwidth}{@{}|Y|Y|Y|@{}}\hline % how to automate this?
% instead of 0.5\textwidth
% use full column width
\href{foo/index.htm}{A}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}&
\href{foo/index.htm}{B}&
\href{foo/index.htm}{C}\\\hline
\end{tabularx}
&
second column
\end{tabular*}
\end{document}
Responder1
Você pode usar \linewidth
. Referência útil será:este Q e seu A. Seria melhor usar p{\dimexpr0.5\textwidth-2\tabcolsep\relax}
para a tabela externa e uma estrutura de célula alinhada à esquerda para enumerate
.
\documentclass[10pt,notitlepage]{article}%
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
%have to use tabular* for outer table since I can't figure how to use tabularx
\noindent\begin{tabular*}{\textwidth}{|p{\dimexpr0.5\textwidth-2\tabcolsep\relax}|
@{\extracolsep{\fill}}p{\dimexpr0.5\textwidth-2\tabcolsep\relax}|}\hline
\begin{tabularx}{\linewidth}{@{}|p{0.35\hsize}|Y|Y|@{}}\hline % how to automate this?
% instead of 0.5\textwidth
% use full column width
{\centering \href{foo/index.htm}{A}\par}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}
&
\href{foo/index.htm}{B}&
\href{foo/index.htm}{C}\\\hline
\end{tabularx}
&
second column
\end{tabular*}
\end{document}
Responder2
veja se é isso que você gostaria de alcançar:
\documentclass[10pt,notitlepage]{article}%
\usepackage{array,tabularx,hyperref}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabularx}{\textwidth}{|@{}X@{}|X|}%outer table, @{} omit column separation
\hline
{\begin{tabularx}{\hsize}{|Y|Y|Y|}
\hline
\href{foo/index.htm}{A}
\begin{enumerate}
\item item 1
\item item 2
\end{enumerate} &
\href{foo/index.htm}{B} &
\href{foo/index.htm}{C} \\
\hline
\end{tabularx}}
& second column \\
\end{tabularx}
\end{document}