There's something wrong with this code:

{\begin{tabularx}{\textwidth}{|l|X|} \hline}

but this is fine:

{\begin{tabular}{|l|l|} \hline}

Why? And how can I get the first to work?

Here is the full LaTeX file:

\documentclass[a4paper, 12pt]{article}

{\begin{tabularx}{\textwidth}{|l|X|} \hline}




latex test.tex


This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&-line parsing enabled.
entering extended mode
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng
erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish,
 french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc
us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por
tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish, 
turkish, ukenglish, ukrainian, loaded.
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/tools/array.sty)) (./test.aux))
Runaway argument?
! File ended while scanning use of \TX@get@body.
<inserted text> 
<*> test.tex

  • In the future please read the documentation of a package before asking a question on a package. This is clearly answered in the tabularx documentation. Jan 26, 2012 at 13:29
  • 26
    @MartinSchröder This sort of attitude slows down progress. Because: it's much faster to type the error message into Google and get the answer on this site, than to read through the package documentation. Now multiply this by hundreds of people around the world. We're talking many hours saved. Jul 30, 2013 at 6:25
  • The same issue occurs with the tabulary package, for which it is not documented. (You also really have to dig in the tabularx to find this issue described.) To help people find this question and solution, using \tabulary and \endtabulary, the error message is ! File ended while scanning use of \TY@get@body..
    – equaeghe
    Jun 1, 2021 at 9:39

2 Answers 2


This is considered "status by design" for tabularx. See the tabularx documentation (section 5 The Macros, p 4).

The way around it is the use the "command form" of the tabularx environment:

  {\tabularx{\textwidth}{|l|X|} \hline}

Your code works fine in my LaTeX implementation, but I've had to add


in the preamble of my document.

Update: try adding content:

Hello & World \\

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .