Search code examples
latexvertical-alignment

Why in overleaf I miss a vertical edges in the table?


enter image description here

I am new in Latex, I create a table

    \begin{table}[!ht]
  \centering
  \caption{Cities analyzed in this study}
  \begin{adjustbox}{max width=\textwidth}
  \begin{tabular}{|l|c|c|c|c|c|c|c|c|c|}
    \hline
    City & Number of & Number of  & \multicolumn{2}{c}{Transportation type}  \\
    \cline{4-9}
    & stations & routes & Bus & Tram & Subway&Rail&Ferry& Cable-car \\
    \hline
    Adelaide & 7548 & 9234 & 8950 &54 & - & 230 & -&- \\
     \hline

But in the top right, the vertical line is not showing. How can I make it appear? My second question how can I put 'Transportation type' on the center of the cell?


Solution

  • You can add the missing edge by using \multicolumn{6}{c|}{...}, but before you actually use this, please have a look at http://betterposters.blogspot.com/2012/08/the-data-prison.html or https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf for some guides about nice table layouts. Using vertical lines is really bad style.

    Please also don't scale elements that contain text. This will make result in a suboptimal usage of font shapes. If you must make your table smaller, manually choose an appropriate font size.

    \documentclass{article}
    
    \begin{document}
    
        \begin{table}[!ht]
      \centering
      \caption{Cities analyzed in this study}
      \begin{tabular}{|l|c|c|c|c|c|c|c|c|c|}
        \hline
        City & Number of & Number of  & \multicolumn{6}{c|}{Transportation type}  \\
        \cline{4-9}
        & stations & routes & Bus & Tram & Subway&Rail&Ferry& Cable-car \\
        \hline
        Adelaide & 7548 & 9234 & 8950 &54 & - & 230 & -&- \\
         \hline
         \end{tabular}
         \end{table}
    
    \end{document}