Empty Pipes



Multi-Page Vertically Centered Latex Table

  • 04 Aug 2015
  • |
  • latex
  • |

Say we wanted to create a latex table that had vertically centered text. Say furthermore that our table was very long and we wanted it to automatically span multiple pages.

Then we might imagine that the table would have a heading…



Followed by an ending at the end of the page…



Which would be continued at the start of the next page…



Such a table can be created using the snippet of code below. It uses the array package for vertically centering the cell text and the longtable package for automatically breaking up the table across multiple pages.

\usepackage{array}
\usepackage{longtable}

\begin{longtable}{ >{\centering\arraybackslash} m{1cm} >{\centering\arraybackslash} m{4cm} >{\centering\arraybackslash} m{4cm}}
PDB ID & Length & Coarse Grain Structure \\
\hline
\endfirsthead

\multicolumn{3}{c}%
{ {\bfseries \tablename\ \thetable{} -- continued from previous page} } \\
\hline PDB ID & Length & Coarse Grain Structure \\
\hline 
\endhead

\hline \multicolumn{3}{|r|} \\ \hline
\endfoot

\hline \hline
\endlastfoot
1GID & 158 & \includegraphics[width=4cm]{gfx/cgs/1GID_A.png} \\
3D0U & 192 & \includegraphics[width=4cm]{gfx/cgs/3D0U_A.png} \\
4GXY & 192 & \includegraphics[width=4cm]{gfx/cgs/4GXY_A.png} \\
\end{longtable}

Stack Exchange References:

  1. How to vertically-center the text of the cells?
  2. Make a table span multiple pages