# How to control width of multicolumn in longtable using tabularx

I have the following table which extends to more than one page. Can someone please help me figure out how to control the width of the columns such that the second and third columns have the largest widths and the other three columns have minimal width with the text center aligned?

I have tried the solutions posted online but my text is either not formatted properly or the table doesn't fit within the page width.

\documentclass{article}

\usepackage{xltabular}

\title{A longtable + tabularx example, using xltabular}

\begin{document}

\begin{xltabular}{\textwidth}{|c|X|X|X|X|}
\caption{Planning overview} \label{tab:long} \\

\hline \multicolumn{1}{|c|}{\textbf{Sl. No}} & \multicolumn{1}{c|}{\textbf{Research Question}} & \multicolumn{1}{c|}{\textbf{Corresponding Experiment}} & \multicolumn{1}{c|}{\textbf{No of weeks}}& \multicolumn{1}{c|}{\textbf{Timeframe}}\\ \hline

\multicolumn{3}{c}%
{\tablename\ \thetable{} -- continued from previous page} \\
\hline \multicolumn{1}{|c|}{\textbf{Sl. No}} & \multicolumn{1}{c|}{\textbf{Research Question}} & \multicolumn{1}{c|}{\textbf{Corresponding Experiment}} & \multicolumn{1}{c|}{\textbf{No of weeks}}& \multicolumn{1}{c|}{\textbf{Timeframe}}\\ \hline

\hline \multicolumn{5}{|r|}{{Continued on next page}} \\ \hline
\endfoot

\hline
\endlastfoot

One & abcdef ghjijklmn & 123.456778 & 1 &  7 Jun - 25 Jun
(parallely with step 4 and 5)\\

\end{xltabular}

\end{document}


The image looks like this:

Probably the following is closer to the expected output?

\documentclass{article}
\usepackage{makecell,calc}
\usepackage{xltabular}

\title{A longtable + tabularx example, using xltabular}

\begin{document}

\begin{xltabular}{\textwidth}{|c|X|X|c|>{\centering\arraybackslash}p{2cm}|}
\caption{Planning overview} \label{tab:long} \\

\caption[]{Planning overview -- continued from previous page} \\

\hline \multicolumn{5}{|r|}{{Continued on next page}} \\ \hline
\endfoot

\hline
\endlastfoot

One & abcdef ghjijklmn & 123.456778 & 1 &  7 Jun - 25 Jun
(parallely with step 4 and 5)\\

\end{xltabular}

\end{document}

• Thank you!!! This is exactly what I was looking for. I would definitely upvote it if I had the rep! :D May 12 at 19:06