1

Im trying to create a multicolumn table in LaTex that would look like this:

enter image description here

I am trying to divide the text into the rows but the code does not work, I have tried in many ways...

\begin{table}[!htb]
    \centering
    \begin{tabular}{|m{2cm}|m{2.5cm}|m{1.5cm}|m{1.5cm}|m{1.5cm}|m{1.5cm}|m{1.5cm}|}
        \hline
        \multicolumn{3}{|p{7cm}|}{\centering \textbf{Fecha de Pago}}  &  \multicolumn{4}{|p{6.5cm}|}{\centering \textbf{Flujo de caja [COP]}}\\
        \hline
        \centering Fecha & \centering D\'ias & \centering Plazo & \centering Bono & \centering Bono & \centering  Bono & \centering Bono \\
        \\
        \\
        \\
        \centering de pago %& \centering de calendatio & _ & \centering TES 1 & \centering TES 2 & \centering TES 3 \centering TES 4 \\



        % &\centering  D\'ias calendario $T^(pay)_n - t$ &\centering  D\'ias calendario $T^(pay)_n - t$ &\centering  Plazo &\centering Bono TES 1 &\centering Bono TES 2 &\centering Bono TES 3 &\centering Bono TES 4 \\

\end{tabular}
\caption{Alguna descripćión.}
\label{tabla:pobconlimsincolor}
\end{table}
3

If it's not necessary to have the exact size of the cell widths you were specifying in centimeters, I would use a package like tabulary. tabulary tries to balance the column widths so that each column has at least its natural width, without exceeding the maximum length.

\documentclass[letterpaper,12pt]{article}
\usepackage[letterpaper,margin=0.75in]{geometry}
\usepackage{tabulary}

\begin{document}

\begin{tabulary}{\textwidth}{|C|C|C|R|R|R|R|}
\hline
\multicolumn{3}{|c|}{\textbf{Fecha de page}} & \multicolumn{4}{c|}{\textbf{Flujo de caja [COP]}}\\
\hline
Fecha de pago $T^{pay}_{n}$&D\'ias de calendario $T^{pay}_{n}-t$&Plazo&Bono TES 1&Bono TES 2&Bono TES 3&Bono TES 4\\
\hline
21/01/2015&90&3M&105&4&6&5,5\\
21/04/2015&180&6M&~&104&6&5,5\\
24/07/2015&274&9M&~&~&106&5,5\\
18/10/2015&360&1Y&~&~&~&105,5\\
\hline
\multicolumn{3}{|c|}{\textbf{Value $V_{t}$[COP]}}&103,70&105,26&113,49&116,2\\
\hline
\end{tabulary}

\end{document}

Which yields the following table:

www

  • Your first row has a | to much. Remove one. – Jan Feb 2 '17 at 5:47
  • Oops, thanks! Edited in the source code above – Lucas Schneider Feb 2 '17 at 5:58
1

To eliminate all those \centering instructions, I suggest you set up a centered version of the m column type. And, use \multicolumn directives, as needed, for the header cells.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{array,lmodern}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably

\begin{document}
\begin{table}[!htb]
\setlength\extrarowheight{2pt} % for a more "open" look
\centering
\begin{tabular}{|M{2cm} | M{2.5cm} | *{5}{M{1.5cm}|}}
\hline
\multicolumn{3}{|c|}{\textbf{Fecha de Pago}} & 
\multicolumn{4}{c|}{\textbf{Flujo de caja [COP]}}\\
\hline
Fecha de pago \newline $T_n^{\mathit{pay}}$& 
D\'ias de calendario $T_n^{\mathit{pay}}-t$ & 
Plazo & Bono TES~1& Bono TES~2 & Bono TES~3 & Bono TES~4 \\
\hline
 & & & & & & \\ % fill in the blanks...
\hline
\multicolumn{3}{c|}{\bfseries\boldmath Value $V_t$[COP]}&
103,70 & 105,26 & 113,49 & 116,2 \\
\cline{4-7}
\end{tabular}
\caption{Alguna descrip\'ción.} % ć ?
\label{tabla:pobconlimsincolor}
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy