1

I made a table with the code below but there are some issues as follows:

  1. The headings are not center aligned
  2. the text in each row do not start at the same point
  3. the spacing between the texts are too much. see image below:

enter image description here

This is my code.

\documentclass[a4paper,11pt,fleqn]{report}
\usepackage[margin=30mm]{geometry}
\usepackage{array}

\begin{document}
    \begin{table}[h!]
        \setlength\extrarowheight{2pt}
        \begin{center}
            \renewcommand{\arraystretch}{1.0}
            \tabcolsep=0.11cm
            \begin{tabular}{m{0.15\linewidth}m{0.2\linewidth}m{0.2\linewidth}m{0.2\linewidth}m{0.2\linewidth}}
                \hline 
                \textbf{Stakeholder} & \textbf{Travel Time} & \textbf{Service Frequency} & \textbf{Accessibility} & \textbf{Operating Cost}\\ 
                \hline
                \textbf{User} & Prefers the most direct routes, in order to reduce travel time & Prefers high frequency service with little or no waiting time &Prefers high proximity and access to the infrastructure like stops and stations to their desired origins and destinations. & Desires the cheapest fare possible for each trip. \\ 
                \textbf{Operator} & Prefers to operate indirect routes, in order to maximize patronage. & Will offer service frequencies that will ensure a maximum utilization of resources and least operational cost. & Prefers central locations where more passengers can access the service irrespective of distance to individual origins and destinations & Desires competitive and profitable fares. \\ 
                \textbf{Agency} & Prefers a travel time that is in line with the agency’s policy. & Prefers service frequencies that reflects the strategic transit goal of the government. & Prefers infrastructure coverage that satisfies most of the community. & Willing to subsidize fares, in order to make it affordable for users and profitable for operators. \\  
                \hline 
            \end{tabular} 
            \caption{Different travel stakeholders and their perceived objectives \label{[Tab1.3:Expanded form of table one whowing more modes and their attributes]}}
        \end{center}
    \end{table}
\end{document}
2
  • When you have very narrow text, it is not a good idea to use justified text. The ragged2e package is useful here >{\RaggedRight\arraybackslash}m{...}. The Headings are not centered as you have not asked them to, they are just (here) a cell bold text in an m column, which is left aligned by default.
    – daleif
    Commented Aug 17, 2017 at 6:51
  • @daleif could you please add a simple implementation of your answer in code. Thanks
    – Nobi
    Commented Aug 17, 2017 at 6:58

3 Answers 3

1

Your tabular environment is not guaranteed to fit inside the width of the textblock. (In fact, it's a bit too wide.) I recommend using a tabualarx environment instead. I would also recommend using the line-drawing macros of the booktabs package instead of using \hline.

enter image description here

\documentclass[a4paper,11pt,fleqn,english]{report}
\usepackage[margin=30mm]{geometry}
\usepackage{tabularx,ragged2e,booktabs,babel}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X} % for columns 2 thru 5
\newcolumntype{C}{>{\Centering\bfseries\arraybackslash}X} % for header cells
\newcommand\mc[1]{\multicolumn{1}{@{}C@{}}{#1}}
\hyphenation{infra-structure}
\begin{document}
    \begin{table}[h!]
        \setlength{\tabcolsep}{3pt} % default value: 6pt
        \begin{tabularx}{\textwidth}{@{} l *{4}{Y} @{}}
        \toprule
        \textbf{Stakeholder} &
        \mc{Travel Time} & \mc{Service Frequency} &
        \mc{Accessibility} & \mc{Operating Cost} 
        \\
        \midrule
        \textbf{User} & Prefers the most direct routes, in order to reduce travel time & Prefers high frequency service with little or no waiting time &Prefers high proximity and access to the infrastructure like stops and stations to their desired origins and destinations. & Desires cheapest fare possible for each trip. \\
        \addlinespace
        \textbf{Operator} & Prefers to operate indirect routes, in order to maximize patronage. & Will offer service frequencies that will ensure a maximum utilization of resources and least operational cost. & Prefers central locations where more passengers can access the service irrespective of distance to individual origins and destinations. & Desires competitive and profitable fares. \\
        \addlinespace
        \textbf{Agency} & Prefers a travel time that is in line with the agency’s policy. & Prefers service frequencies that reflects the strategic transit goal of the government. & Prefers infrastructure coverage that satisfies most of the community. & Willing to subsidize fares, in order to make it affordable for users and profitable for operators. \\
        \bottomrule
        \end{tabularx}
        \caption{Different travel stakeholders and their perceived objectives} 
        \label{Tab1.3} % there's no point in having an overly long \label
    \end{table}
\end{document} 
1
  • Thank you, Mico. the tabularx package definitely works betters for this case!
    – Nobi
    Commented Aug 17, 2017 at 8:27
3

here is one. However, I'd recommend rewriting this anyway (no suggestions on how), this is never going to look good or be nice to read.

\documentclass[a4paper,11pt,fleqn]{report}
\usepackage[margin=30mm]{geometry}
\usepackage{array,ragged2e}

\begin{document}
    \begin{table}[h!]
        \setlength\extrarowheight{2pt}
        \begin{center}
            \renewcommand{\arraystretch}{1.0}
            \tabcolsep=0.11cm
            \begin{tabular}{ 
                >{\RaggedRight\arraybackslash} m{0.15\linewidth}
                >{\RaggedRight\arraybackslash} m{0.2\linewidth}
                >{\RaggedRight\arraybackslash} m{0.2\linewidth}
                >{\RaggedRight\arraybackslash} m{0.2\linewidth}
                >{\RaggedRight\arraybackslash} m{0.2\linewidth}
              }
                \hline 
                \Centering \textbf{Stakeholder} 
                & 
                \Centering\textbf{Travel Time} 
                & 
                \Centering \textbf{Service Frequency} 
                & 
                \Centering \textbf{Accessibility} 
                & 
                \Centering \textbf{Operating Cost}
                \\ 
                \hline
                \textbf{User} & Prefers the most direct routes, in order to reduce travel time & Prefers high frequency service with little or no waiting time &Prefers high proximity and access to the infrastructure like stops and stations to their desired origins and destinations. & Desires the cheapest fare possible for each trip. \\ 
                \textbf{Operator} & Prefers to operate indirect routes, in order to maximize patronage. & Will offer service frequencies that will ensure a maximum utilization of resources and least operational cost. & Prefers central locations where more passengers can access the service irrespective of distance to individual origins and destinations & Desires competitive and profitable fares. \\ 
                \textbf{Agency} & Prefers a travel time that is in line with the agency’s policy. & Prefers service frequencies that reflects the strategic transit goal of the government. & Prefers infrastructure coverage that satisfies most of the community. & Willing to subsidize fares, in order to make it affordable for users and profitable for operators. \\  
                \hline 
            \end{tabular} 
            \caption{Different travel stakeholders and their perceived objectives \label{[Tab1.3:Expanded form of table one whowing more modes and their attributes]}}
        \end{center}
    \end{table}
\end{document}
4
  • is it possible to make all the rows text start at the same point, or is that what you imply by "needing a rewrite"?
    – Nobi
    Commented Aug 17, 2017 at 7:19
  • What exactly do you mean by starting at the same point? Try p{...} instead of m{...}. I would completely rethink this.
    – daleif
    Commented Aug 17, 2017 at 7:26
  • 1
    Your solution (which is, obviously, based on the OP's code) doesn't guarantee that the table fits inside with width of the texblock. Indeed, the table is currently a bit wider than the textblock.
    – Mico
    Commented Aug 17, 2017 at 8:18
  • @Mico that is of course due to the choices for the column width
    – daleif
    Commented Aug 17, 2017 at 9:58
2

considering all comments + added rules from booktabs package + thead from makecell

edit: and considering mico comment regarding table width. this can be simply accomplish with use tabularx table environment as follows:

enter image description here

\documentclass[a4paper,11pt,fleqn]{report}
\usepackage[margin=30mm]{geometry}
\usepackage{ragged2e}
\usepackage{array, booktabs, makecell, tabularx}
\renewcommand\theadfont{\bfseries\small}

\usepackage{lipsum}

\begin{document}
\lipsum[11] % for see the text width
    \begin{table}[h!]
    \centering
\begin{tabular}{@{}>{\bfseries} l
                *{4}{>{\RaggedRight}X}
                @{}}
    \toprule
\thead[b]{Stake\-\\holder} & \thead[b]{Travel Time} & \thead[b]{Service\\ Frequency} & \thead[b]{Accessibility} & \thead[b]{Operating Cost}\\
    \midrule
User        & Prefers the most direct routes, in order to reduce travel time & Prefers high frequency service with little or no waiting time &Prefers high proximity and access to the infrastructure like stops and stations to their desired origins and destinations. & Desires the cheapest fare possible for each trip. \\
    \addlinespace
Operator    & Prefers to operate indirect routes, in order to maximize patronage. & Will offer service frequencies that will ensure a maximum utilization of resources and least operational cost. & Prefers central locations where more passengers can access the service irrespective of distance to individual origins and destinations & Desires competitive and profitable fares. \\
    \addlinespace
Agency  & Prefers a travel time that is in line with the agency’s policy. & Prefers service frequencies that reflects the strategic transit goal of the government. & Prefers infrastructure coverage that satisfies most of the community. & Willing to subsidize fares, in order to make it affordable for users and profitable for operators. \\
    \bottomrule
\end{tabular}
    \caption{Different travel stakeholders and their perceived objectives
\label{[Tab1.3:Expanded form of table one whowing more modes and their attributes]}}
    \end{table}
2
  • Your solution doesn't guarantee that the table will actually fit inside the textblock. (Indeed, the table's a bit wider than the textblock.)
    – Mico
    Commented Aug 17, 2017 at 8:07
  • @mico, as usual ... you have right. i didn't give any attention to this. use of tabularx with combinationof c and >{Raggedright}X columns is far better. i will correct answer.
    – Zarko
    Commented Aug 17, 2017 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .