0

I guess this is somewhat easy but I'm struggling with it for a while right now. How can I make such a table that fits perfectly to the given page layout and has (automatic) line breaks and the first row colored in black? And is it possible that (the last parts of) this table can be broken to the next page too if it does not fully fit at the end of the previous page?

enter image description here

Thank you so much.

Ferit
  • 371

2 Answers2

2

For example with tabularx:

\begin{table}[htb]
   \caption{My table}
   \label{my table}
   \begin{tabularx}{\textwidth}{p{22mm}>{\raggedright}X>{\raggedright}Xp{33mm}}
     \rowcolor{black}
     \textcolor{white}{Column 1}
       & \texcolor{white}{Column 2}
           & \textcolor{white}{Column 3}
               & \textcolor{white}{Column 4}   \\
     A & B & C & D                             \\
   \end{tabularx}
\end{table}

For more, please provide minimal but complete document (starting with \documentclass{...} and ending with \end{document}), which will show your attempts so far. Based on it, I can (easily) complete my code to a MWE (just now I haven't to make MWE from scratch).

Edit: If your really like to star table at page border, than you question is duplicate to question the-inserted-picture-does-not-start-from-the-left-edge-of-the-paper. See, if answer there gives what you like to obtain. In your case you than only need to adopt tabularx width to page width.

Zarko
  • 296,517
1

For a table which 1) fits the text width; 2) can break across pages, you can use the ltablex package, which brings the functionalities of longtable to tabularx. Add the directive \keepXColumns so that X columns will have their calculated width. Otherwise, they will have their natural width up to the calculated width.

Bernard
  • 271,350