15

I would like to create a table whose width should be the minimum possible (lines don't wrap). I see that tabularx wants a width parameter, is it possible to specify something like "auto", instead, for example, of \linewidth?

  • 10
    that is done by a simple tabular environment – user2478 Sep 11 '12 at 13:42
  • @Herbert I guess that should be made the answer:-) – David Carlisle Dec 13 '12 at 0:18
  • Do you need to use tabularx or are you fine with some other table? – Mayou36 May 31 '17 at 19:03
13

You don't need tabularx for your specifications. tabular is enough here.

\begin{tabular}{l r c}
foo & bar & and so on
\end{tabular}

is a tabular with a minimum width and default column separation width

\begin{tabular}{@{} l r c @{}}
foo & bar & and so on
\end{tabular}

is a tabular with no column separation on the left and right

{\setlength\tabcolsep{0pt}%
\begin{tabular}{l r c}
foo & bar & and so on
\end{tabular}}

is a tabular with no column separation anyway

\begin{tabular}{l @{} r c }
foo & bar & and so on
\end{tabular}

is a tabular with no column separation between the first and second column

\begin{tabular}{l @{\hspace{5mm}} r c }
foo & bar & and so on
\end{tabular}

is a tabular with a column separation of 5mm between the first and second column

  • 6
    The question was about tabularx. You used tabular. – buhtz Dec 11 '16 at 10:58
  • 2
    Sure, but there is no need for a tabularx for what the original poster asked for! – user2478 Dec 11 '16 at 14:10
  • 5
    You don't know what he wants. You only know he wants a tabularx, but everything else is unknown. Let's pretend the OP is clever and knows why he wants to use a tabularx but on the other hand does not spam us with all the reasons he needs one and only asks one specific question. Which you unfortunately failed to answer. – Mayou36 May 31 '17 at 16:08
  • @Mayou36: You should read the question, then you know what he/she wants ... – user2478 May 31 '17 at 16:18
  • @Herbert, I agree that his first sentence seems to be general. But on one hand, he asks for a possible argument and on the other hand, the title says it all... But to be sure, I just asked the OP ;) – Mayou36 May 31 '17 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.