How do I create my own new environment of a selfscaling tabularx table, as well as a caption added to it and maybe colored rows? The caption should not be added using the odd flowing captionof command, but rather in a real tabular environment.

If I add \begin{tabularx} in a \newenvironment or the command form \tabularx after a \begin{table}, I always get this error:

File ended while scanning use of \TX@get@body.
  • Welcome to TeX.SX! Related/duplicate: tex.stackexchange.com/questions/42325/… – TeXnician Aug 22 '18 at 9:12
  • 1
    This is what i found first, but I had a really hard time figuring out how to add the table environment as well. This was important, in order have a caption attached to the table and not have the stragely floating captionof. – Xerusial Aug 22 '18 at 9:18
  • That's why I didn't vote to close, because I think it's a good standalone question :) – TeXnician Aug 22 '18 at 9:21

The problem with the tabularx environment is, that it is not an actual environment. It is a wrapped command somehow denying any \end after the actual \endtabularx. The solution is to use the command form for both table and tabularx.


This is a complete Tex Sample for the table below.



%Table header
    \textcolor{white}{\sffamily\bfseries #1}}

%New centered X column named Y

%Table environment
    \caption{#2 \label{#3}}

        \sthead{X Column} & \sthead{Y Column}\\
        The quick brown fox jumps over \newline the lazy dog & The quick brown fox jumps over the lazy dog\\

Results in:

Tabulax environment example code

| improve this answer | |

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.