I'd like to let LaTeX split a formula that's inside a fixed-width table. The formula is a group theoretical word (something like $a_1b_3a_5b_3^{-1}$).
It should automatically split it somewhere between the elements so that it fits in the table. I thought seqsplit might do the trick, but in the following code example:
\documentclass{article}
\usepackage{seqsplit}
\begin{document}
\begin{tabular}{p{4cm}}
\seqsplit{$a_1b_3a_5b_3^{-1}$}\\
\seqsplit{$a_1$ $b_3$ $a_5$ $b_3^{-1}$}\\
\seqsplit{abcd}
\end{tabular}
\end{document}
Both variants with the formula just raise lots of errors of the form Missing { inserted \seqsplit{$a_1b_3a_5b_3^{-1}$}, whereas the abcd-sample works.
The second example actually wouldn't give the desired result anyway, because there should be no spaces between the elements.
Does anyone have a solution to this?


amsmathpackage. It offers many environments for "math problems" (including splitting equations over several lines). – Dr. Manuel Kuehner Sep 12 '17 at 17:10\\\), i.e. it doesn't split automatically, as far as I know. – magula Sep 12 '17 at 17:18\seqsplit(which is not relevant here anyway), works fine. – Bernard Sep 12 '17 at 17:18>{\raggedright}p{4cm}. You'll get a more or less important white space at the end of the lines, but not between the elements. If it's OK for you, you also can write>{\centering}p{4cm}. – Bernard Sep 12 '17 at 17:31arrayfor that (without that, it doesn't compile)? I still get spaces between the elements (even though there somehow seems to be a longer space in the first line without that change). – magula Sep 12 '17 at 17:46