Question
Currently, I'm trying to shorten the creation of small tabularx-tables with pre-defined headers, but somehow, trying to use the tabularx-environment, even though I used the \tabularx and \endtabularx commands, inside my own yields to errors I fail to understand.
My current approach:
\newenvironment{predtable}[1]%
{%
\par\nolinenumbers%
\captionof{table}{#1}%
\tabularx{\textwidth}{|l| c c c |}%
\hline%
& Heading & Heading & Heading \\%
\hline%
}%
{%
\hline%
\endtabularx%
\linenumbers%
}
This was supposed to ease table creation such that writing
\begin{predtable}
item1 & item2 & item3 & item4\\
\end{predtable}
would be enough.
However, while I don't get errors when defining the environment, using it gets me the error Misplaced \noalign \end{predtable}.
Working example
\documentclass[12pt,a4paper]{article}
\usepackage[top=2.5cm, left=2.5cm, bottom=2cm, right=2cm]{geometry}
\usepackage{array}
\usepackage{tabularx}
\usepackage[font=footnotesize,labelfont=sc]{caption}
\usepackage{subcaption}
\usepackage[pagewise, modulo]{lineno}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newenvironment{predtable}[1]%
{%
\par\nolinenumbers%
\captionof{table}{#1}%
\tabularx{\textwidth}{|l| C C C |}%
\hline%
& Heading 1 & Heading 1 & Heading 1 \tabularnewline%
\hline%
}%
{%
\hline%
\endtabularx%
\linenumbers%
}
\begin{document}
\begin{predtable}{Caption goes here!}
Label & Contents & go & here!\tabularnewline
\end{predtable}
\end{document}
line 26: Misplaced \noalign \end{predtable}


\tabularxinstead of the environment) and added the error I'm getting. – Big-Blue Feb 23 '13 at 18:37\documentclassto\end{document}? This way we wouldn't need to guess at what package you're using. – egreg Feb 23 '13 at 23:25tabularx-tables work fine. – Big-Blue Feb 24 '13 at 09:00\\before\hline. Try input\\. – Apr 30 '13 at 05:32