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.

  • you might want to have a look at the tabularx package – ArTourter Oct 24 '16 at 13:13
  • tabulary is less know, but also handy! – ebosi Oct 24 '16 at 13:18
  • Please add to your question a minimal document, which will show your attempt so far. Do you really mean that table should be extended to page border and not of text ones? – Zarko Oct 24 '16 at 15:16
  • Have you tried with longtable instead of tabularx to break the table to the net page? – Dario Oct 24 '16 at 19:24
  • Related/duplicate: My table doesn't fit; what are my options? – Werner Oct 25 '16 at 9:57
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.

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.

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.