
Quiero centrar horizontalmente una tabla que se genera con tabularx. Pero la tabla tabularx tiene un desplazamiento hacia la derecha que no puedo eliminar:
\begin{table}
\small
\centering
\noindent
\begin{tabularx}{}{@{}X|X|X@{}}\hline
a & b & c \\ \hline
d & e & f
\\\hline
\end{tabularx}
\caption{This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. This table is generated with tabularx. }
\end{table}
\begin{table}
\small
\centering
\noindent
\begin{tabular}{ccc}\hline
a & b & c \\ \hline
d & e & f
\\\hline
\end{tabular}
\caption{This table is generated with tabular. This table is generated with tabular. This table is generated with tabular. This table is generated with tabular. This table is generated with tabular. This table is generated with tabular.}
\end{table}
¿Cómo puedo centrar horizontalmente la mesa en tabularx?
Respuesta1
tabularx
requiere que especifique un ancho de la tabla resultante para que pueda calcular el ancho de X
las columnas. Entonces, úsalo así:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}[t]
\small
\centering
\begin{tabularx}{10em}{ @{} X | X | X @{} }
\hline
a & b & c \\
\hline
d & e & f \\
\hline
\end{tabularx}
\caption{This table is generated with \texttt{tabularx}.}
\end{table}
\begin{table}[t]
\small
\centering
\begin{tabular}{ *{3}{c} }
\hline
a & b & c \\
\hline
d & e & f \\
\hline
\end{tabular}
\caption{This table is generated with \texttt{tabular}.}
\end{table}
Some regular text.
\end{document}