1

I am trying to make a table in latex. But I'm not able to center what I write in the header and later I also wanted to write in each block below some writing and that this is not all in the same line (if you understand me).

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tikz}

\begin{document}
\listoftables

\vspace{1cm}

\begin{table}[ht]
    \caption{Exemplos de Modelos de Previsão de Tráfego}
    \label{tab:hla:modelos}
    \centering
    \begin{tabular}{lllllll}
       \toprule
         \multicolumn{1}{c}{\parbox{1cm}{\centering\textbf{Paper}}} & \parbox{1cm}{\centering\textbf{Método}} & \parbox{2cm}{\centering\textbf{Fonte\\de\\Dados}} & \parbox{2cm}{\centering\textbf{Parâmetros\\de\\ Entrada}} & \parbox{2cm}{\centering\textbf{Horizonte\\de\\Previsão}} & \parbox{2cm}{\centering\textbf{ Período\\de\\ Estudo}} \\
        \midrule
        \cite{Beckman08}    & ANN & GPS,Detetor de Veículos,Base de dados de incidentes & Velocidade, Volume,Ocupação,Data& Long-term 1 day Short-term 15 min & 1 \\
        \cite{Artho03}      & 1 & 4 & 1 & 1 & 1 \\
        \cite{Artho03}      & 1 & 2 & 1 & 1 & 1 \\
        \cite{Artho03}      & 1 & 1 & 1 & 1 & 1 \\
        \cite{Artho04}      & 1 & 4 & 1 & 1 & 1 \\
        \cite{Artho04}      & 0 & 7 & 0 & 1 & 1 \\
        \cite{Artho04}      & 0 & 2 & 0 & 1 & 1 \\
        \cite{Flanagan04}   & 1 & 0 & 0 & 1 & 1 \\
        \cite{Praun03}      & 1 & 1 & 1 & 1 & 1 \\
        \cite{Praun03}      & 1 & 2 & 1 & 1 & 1 \\
        \bottomrule
    \end{tabular}
\end{table}

\vspace{1cm}

\end{document}

and this is the output after write in column: enter image description here before write: enter image description here

1
  • any news? do any of received answers help you?
    – Zarko
    Apr 6 '18 at 13:33
2

like this?

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\bfseries\small}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\RaggedRight}X}
\newcommand\mcx[1]{\multicolumn{1}{L}{#1}}

\begin{document}

\begin{table}[ht]
    \caption{Exemplos de Modelos de Previsão de Tráfego}
    \label{tab:hla:modelos}
    \centering
    \small
    \setlength\tabcolsep{4pt}
    \begin{tabularx}{\linewidth}{@{} lc cc c c @{}}%ll ll l
       \toprule
\thead[b]{Paper}
    &   \thead[b]{Método}
        &   \thead[b]{Fonte\\de Dados}
            &   \thead[b]{Parâmetros\\de Entrada}
                &   \thead[b]{Horizonte\\de Previsão}
                    &   \thead[b]{Período\\de  Estudo}  \\
        \midrule
\cite{Beckman08}
    &   ANN
        &   \mcx{GPS, Detetor de Veículos, Base de dados de incidentes }
            &   \mcx{Velocidade, Volume, Ocupação, Data}
                &   \mcx{Long-term 1 day Short-term 15 min}
                                    & 1 \\
\cite{Artho03}      & 1 & 4 & 1 & 1 & 1 \\
\cite{Artho03}      & 1 & 2 & 1 & 1 & 1 \\
\cite{Artho03}      & 1 & 1 & 1 & 1 & 1 \\
\cite{Artho04}      & 1 & 4 & 1 & 1 & 1 \\
\cite{Artho04}      & 0 & 7 & 0 & 1 & 1 \\
\cite{Artho04}      & 0 & 2 & 0 & 1 & 1 \\
\cite{Flanagan04}   & 1 & 0 & 0 & 1 & 1 \\
\cite{Praun03}      & 1 & 1 & 1 & 1 & 1 \\
\cite{Praun03}      & 1 & 2 & 1 & 1 & 1 \\
        \bottomrule
    \end{tabularx}
\end{table}
\end{document}
2

Use tabularx, and makecell to simplify the code of the column headers. Also, caption to have a decent vertical spacing between caption and table:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}
\usepackage{caption, booktabs, tabularx, makecell}
\renewcommand{\theadfont}{\normalsize\bfseries}

\begin{document}

\listoftables
\vspace{1cm}

\begin{table}[ht]
    \caption{Exemplos de Modelos de Previsão de Tráfego}
\setlength{\tabcolsep}{3pt}
    \label{tab:hla:modelos}
    \centering
    \begin{tabularx}{\linewidth}{cc*{3}{ >{\centering}X}c}
       \toprule
         \thead{Paper} & \thead{Método} & \thead{Fonte\\de Dados} & \thead{Parâmetros\\de Entrada} & \thead{Horizonte\\de Previsão} & \thead{Período\\de Estudo}\\
        \midrule
        \cite{Beckman08} & ANN & \RaggedRight GPS, Detetor de Veículos, Base de dados de incidentes & \RaggedRight Velocidade, Volume, Ocupação, Data & \RaggedRight Long-term 1 day Short-term 15 min & 1 \\
        \cite{Artho03} & 1 & 4 & 1 & 1 & 1 \\
        \cite{Artho03} & 1 & 2 & 1 & 1 & 1 \\
        \cite{Artho03} & 1 & 1 & 1 & 1 & 1 \\
        \cite{Artho04} & 1 & 4 & 1 & 1 & 1 \\
        \cite{Artho04} & 0 & 7 & 0 & 1 & 1 \\
        \cite{Artho04} & 0 & 2 & 0 & 1 & 1 \\
        \cite{Flanagan04} & 1 & 0 & 0 & 1 & 1 \\
        \cite{Praun03} & 1 & 1 & 1 & 1 & 1 \\
        \cite{Praun03} & 1 & 2 & 1 & 1 & 1 \\
        \bottomrule
    \end{tabularx}
\end{table}

\end{document} 

enter image description here

2
  • In this case i have a problem write in last column
    – user147460
    Nov 5 '17 at 23:50
  • 1
    Which problem exactly?
    – Bernard
    Nov 5 '17 at 23:52

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.