0

I am hunting for hbox badnesses in my document at the moment and have some problems in resolving issues with a table using tabularx. As suggested in this thread I am using \raggedright to relax the typesetting problems due to line breaking. But however, when I do so in the last column, it produces some errors indicating a missplaced \noalign. Now I am a little confused, what the actual error is, I am doing here.

The \mbox in the MWE are used to prevent unwanted line breaking.

MWE:

\documentclass{letter}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\textwidth}{X|X|X|X|X|X}
    \raggedright TIC & \raggedright \mbox{absolute} shot number & \raggedright recorded proton spectra & \raggedright modulated proton spectra & \raggedright highest cut-off energy (MeV) & \raggedright avg. \mbox{cut-off} energy (MeV) \\
    \hline $2\times 10^{-13}$  & 150 & 88.6\% & 31.6\% & 14.1 & $6.8 \pm 1.8$
\end{tabularx}
\end{document}

This is the result I get, if I don't set the last column header to raggedright, but producing underfull boxes:

last column without \raggedright

And this is the way it looks, when setting the last column header to \raggedright:

last column set to \raggedright

Obviously this leads to some misinterpretation of where the linebreak has to be.

1

You need to use \tabularnewline to end the table row, or use \raggedright\arraybackslash to reset \\ to its tabular meaning, as \raggedright redefines \\ to do a ragged text line end.

You can use >{\raggedright\arraybackslash}X to save adding this in every cell explicitly.

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.