# Centre a long table?

\begin{longtable}{|l|l|l|l|}

\textbf{Test} & \textbf{Input into all tests} & \textbf{\begin{tabular}[c]{@{}l@{}}Expected Result\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}Actual \end{tabular}} \\ \hline
1 & \begin{tabular}[c]{@{}l@{}}x\\ \{[]\}\end{tabular} & \begin{tabular}[c]{@{}l@{}}x \end{tabular} & x\\ \hline
\end{longtable}


That is the first two rows of my table

However my table is quite wide and at the minute it lines up with the left margin and then is spread to the edge of the page on the right. How do I get the table to sit in the centre of the page?

• Welcome to TeX.SE. I'm afraid there are very few (reliable) psychics that frequent this site. You'll need to post an MWE to show us what your table contains. – Mico Apr 13 '15 at 12:49
• I've added the first two rows of the table – user76135 Apr 13 '15 at 12:55
• Is there any reason for the tabular within longtable? – user31729 Apr 13 '15 at 13:00
• Two observations: (i) As posted, the longtable does not exceed the width of the text block, and (ii) many of the cells seem to contain tabular environments that don't do anything useful. How can we help? – Mico Apr 13 '15 at 13:01
• @user76135: If you want to center some stuff in a column that is not c, use \multicolumn{1}{c}{some stuff}, wrapping use a p or similar column – user31729 Apr 13 '15 at 13:04

Unsure what is really wanted, but some 'improvements' of the table.

Wrapping of text inside a table cell can be achieved with makecell package and \thead macro.

The tabular environments are of no use here and can be replaced by \multicolumn statements. I kept the @{} stuff, although not useful here (in my point of view)

\documentclass{article}

\usepackage{makecell}
\usepackage{longtable}

\begin{document}

\begin{longtable}{|*{4}{l|}}
\centering
\textbf{Test} & \textbf{Input into all tests} & \textbf{\begin{tabular}[c]{@{}l@{}}Expected Result\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}Actual \end{tabular}} \\ \hline
1 & \begin{tabular}[c]{@{}l@{}}x\\ \{[]\}\end{tabular} & \begin{tabular}[c]{@{}l@{}}x \end{tabular} & x\\
\hline
& & & \tabularnewline
\textbf{Test} & \textbf{Input into all tests} & \multicolumn{1}{@{}c@{}|}{\textbf{Expected Result}} & \multicolumn{1}{c|}{\textbf{Actual}} \\
& & & \tabularnewline
\hline
1 & \thead[l]{x \\ \{[]\}} & \multicolumn{1}{@{}c@{}|}{x}  & x\\
\hline
\end{longtable}

\end{document}