2

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 
\endfirsthead

\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 
\endhead

\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: Current image

2

Probably the following is closer to the expected output?

enter image description here

\documentclass{article}
\usepackage{makecell,calc}
\renewcommand{\theadfont}{\bfseries}
\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} \\

\hline \thead{Sl. No} & \thead{Research\\ Question} & \thead{Corresponding\\ Experiment} & \thead{No of\\ weeks}&\thead{Timeframe}\\ \hline 
\endfirsthead

\caption[]{Planning overview -- continued from previous page} \\
\hline \thead{Sl. No} & \thead{Research\\ Question} & \thead{Corresponding\\ Experiment} & \thead{No of\\ weeks}&\thead{Timeframe}\\ \hline 
\endhead

\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}
1
  • Thank you!!! This is exactly what I was looking for. I would definitely upvote it if I had the rep! :D
    – user42
    May 12 at 19:06

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.