1

I have a created a table in LaTeX which goes straight out of the page on the right side (fig shown). This is a 14 by 6 table. The kind of format I want to achieve is something like the one given in MS word. MS word table

Table in latex I’ve created:

booktabs table

The skeleton i've used:

\documentclass{article}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[margin=1in]{geometry} 
\usepackage{pdflscape}
\usepackage{graphicx}

\begin {document} \setlength\LTleft{0pt} \setlength\LTright{0pt} \begin{longtable}{@{\extracolsep{\fill}}|*{6}{c|}} \caption{Multipage table.} \label{tab:table1}\

\toprule \textbf{Author} & \textbf{Year of Publication} & \textbf{Mainly focusing problem/area} & \textbf{Any specific layered architecture} & \textbf{Main points} & \textbf{Any observable fault} \

\midrule \endfirsthead

\toprule \textbf{Author} & \textbf{Year of Publication} & \textbf{Mainly focusing problem/area} & \textbf{Any specific layered architecture} & \textbf{Main points} & \textbf{Any observable fault} \

\midrule \endhead %...My 14 rows each accommodating 6 columns…% \bottomrule \end{longtable}

\end{document}

How can I adjust the table in \texwidth and allow it to vertically expand? The reason I used booktabs here, is to allow the table to go on the next page (if required).

P.S. I also used tabularx (image attached), but the problem is, table doesn’t fit the whole page (last 2 rows are attached but not displayed due to margins I guess), given a reasonable format.

latex table using tabularx:

enter image description here

Skeleton for creating table using tabularx

\documentclass{article}

\usepackage{geometry} % more generous margins \usepackage{tabularx} \renewcommand*{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{table}[t!] \caption{Comparison of some unique works in IoT Transportation} \begin{tabularx}{\textwidth}{|*{6}{X|}} %....% \end {tabularx} \end{tabular} \end{document}

For reference, ive also consulted the following links, but couldn't manage to solve my problem: Link1 Link2 Link3

afaq
  • 347
  • Since you mention "The reason I used booktabs here, is to allow the table to go on the next page": booktabs has nothing to do with allowing table to span multiple pages. booktabs provides horizontal lines with improved spacing sich as \toprule, \midrule and \bottomrule thatn can be used instead of \hline. Packages that allow ables to occupy multiple pages include longtable, xltabularand tabularray. – leandriis Mar 05 '22 at 17:51
  • @leandriis, i kind of didn't mention the whole scenario. i am using both booktabs and longtable as shown in above code, but still couldn't get the format right – afaq Mar 05 '22 at 18:25
  • @PeterWilson, it does solve the formatting problem (i.e. text and margins are set to make it readable), but the whole table in latex doesn't fit on the same page, rather just cuts of (as shown in image). that's why i tried to solve the problem via booktabs & longtable but couldn't get the formatting right plus table goes out of the page. – afaq Mar 05 '22 at 18:27
  • booktabs explicitly documents that it should not be used for tables with vertical rules. The table would look a lot better wihout the vertical lines but if you do want them do not use booktabs. – David Carlisle Mar 05 '22 at 18:33
  • just use longtable but change *{6}{c|} as c columns are 1-line text: you want something like llp{3cm}lp{3cm}p{3cm} choosing whatever widths you need. – David Carlisle Mar 05 '22 at 18:35

0 Answers0