# How to draw a table (1+2*1)+(1+3*1) in tabular

I want to draw such table in tabular

following code of using two tables is very easy to understand in the previous answer when there is no first row.

\documentclass{article}
\begin{document}

\begin{tabular}{|@{} l @{}|@{} c @{}|}\hline
\begin{tabular}{ l }
some text in the left\\\cline{1-1}
some more text in the left column\\
\end{tabular}
&
\begin{tabular}{ l }
some text in the left\\\hline
some text in the left\\\hline
some more text in the left column
\end{tabular}\\\hline
\end{tabular}

\end{document}


But in my real situation, there is a additional row at the top of each table, their height should be equal.

here is my real code:

\begin{tabular}{@{} l @{}|@{} l @{}}
\toprule
\begin{tabular}{ l|l }
\multirow{2}{*}{Ticker} & \multirow{2}{*}{Types}\\
&
\end{tabular}
&
\begin{tabular}{l|l|l|l|l}
\multirow{2}{*}{Strikes}  & Up        & Down              & Up/Down    & \multirow{2}{*}{BarrierTypes}\\
& Barriers  & Barriers          & LevelInit  &
\end{tabular}\\
\hline\hline
\begin{tabular}{ l|l }
Trade A & Vanilla\\\hline
Trade A & Vanilla\\\hline
Trade A & Vanilla\\\hline
Trade A & Vanilla\\\hline
Trade A & Vanilla\\\hline
Trade A & Vanilla
\end{tabular}
&
\begin{tabular}{ l|l|l|l|l }
max(1.05*S+4, 1.10*S)     & \multirow{4}{*}{1.1*S}        & \multirow{4}{*}{0.9*S}  & \multirow{8}{*}{\shortstack{1.2*TS/\\0.8*TS}} & \multirow{8}{*}{\shortstack{Continuous/\\Out}}\\
min(1.05*S+4, 1.10*S)     &                               & & &           \\
min(1.05*S+8, 1.10*S)     &                               & & &           \\
min(1.05*S+8, 1.10*S+4)   &                               & & & \\ \cline{1-3}
S                         & x*S,                          & \multirow{4}{*}{0}      &                                               &  \\
1.05*S                    & Multiplier x                  & & &           \\
min(1.05*S+4, 1.10*S)     &  moving as                    & & &           \\
max(1.05*S+4, 1.10*S)     & x-variable                    & & &   \\
\end{tabular}\\
\bottomrule
\end{tabular}


Here is the result

I don't know why the left-bottom part will be such figure and the column line of first row seems wrong.

What I want to get is like this

• your real table is very different from the first sketch of table. please, consider ask new question. – Zarko Jun 28 '18 at 5:44
• yes, once I simply recognized them as the same type of tables – user6703592 Jun 28 '18 at 6:02

With some \multirow, \multicolumn, \makecell and some little tricks for a better spacing (\renewcommand{\arraystretch}{1.4} and \rule{0pt}{...}), your table can be created without nesting tabulars, but is larger than the page width of an ordinary article class. Maybe you have to put it sideways.

\documentclass{article}
\usepackage{array}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}

{\renewcommand{\arraystretch}{1.4}\noindent\small%
\begin{tabular}{|*9{c|}}
\hline
\rule{0pt}{4ex}Ticker & Types & Strikes  & \makecell{Up\\Barries} & \makecell{Down\\Barriers} & \makecell{Up/Down\\LevelInit} & \multicolumn{3}{c|}{BarrierTypes} \\
\hline
Trade A & Vanilla & \multicolumn{3}{c|}{\multirow{3}{*}{\makecell{\rule{0pt}{2.5ex}max(1.05*S+4, 1.10*S)\\min(1.05*S+4, 1.10*S)\\min(1.05*S+8, 1.10*S)\\min(1.05*S+8, 1.10*S+4)}}} & \multirow{3}{*}{\makecell{\rule{0pt}{2.5ex}1.1*S}}& \multirow{3}{*}{0.9*S}&\multirow{6}{*}{\makecell{1.2*TS/\\0.8*TS}}&\multirow{6}{*}{\makecell{Continuous/\\Out}}\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\cline{1-7}
Trade A & Vanilla & \multicolumn{3}{c|}{\multirow{3}{*}{\makecell{\rule{0pt}{2.5ex}S\\
1.05*S     \\
min(1.05*S+4, 1.10*S)      \\
max(1.05*S+4, 1.10*S)}}}&
\multirow{3}{*}{\makecell{\rule{0pt}{2.5ex}x*S\\
Multiplier x    \\
moving as          \\
x-variable}}
&\multirow{3}{*}{0}&&\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\hline
\end{tabular}%
}

\end{document}


Edit: If this is what you want (but I prefer the other way or leandriis's solution, because in this way there is a lot of unused space and the table is already wide).

Re-edit: To avoid \makecell, \shortstack seems to work.

\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}

{\renewcommand{\arraystretch}{1.6}\noindent\footnotesize%
\begin{tabular}{|*9{c|}}
\hline
Ticker & Types & Strikes  & UpBarries & DownBarriers & Up/DownLevelInit & \multicolumn{3}{c|}{BarrierTypes} \\
\hline
Trade A & Vanilla & \multicolumn{3}{c|}{\multirow{3}{*}{\shortstack{\rule{0pt}{2.5ex}max(1.05*S+4, 1.10*S)\\min(1.05*S+4, 1.10*S)\\min(1.05*S+8, 1.10*S)\\min(1.05*S+8, 1.10*S+4)}}} & \multirow{3}{*}{\shortstack{\rule{0pt}{2.5ex}1.1*S}}& \multirow{3}{*}{0.9*S}&\multirow{6}{*}{\shortstack{1.2*TS/\\0.8*TS}}&\multirow{6}{*}{\shortstack{Continuous/\\Out}}\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\cline{1-7}
Trade A & Vanilla & \multicolumn{3}{c|}{\multirow{3}{*}{\shortstack{\rule{0pt}{2.5ex}S\\
1.05*S     \\
min(1.05*S+4, 1.10*S)      \\
max(1.05*S+4, 1.10*S)}}}&
\multirow{3}{*}{\shortstack{\rule{0pt}{2.5ex}x*S\\
Multiplier x    \\
moving as          \\
x-variable}}
&\multirow{3}{*}{0}&&\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\cline{1-2}
Trade A & Vanilla & \multicolumn{3}{c|}{}&&&&\\
\hline
\end{tabular}%
}

\end{document}


• Exactly! But how to put the contexts of column1 row2 and column1 row3 at center of the cell. – user6703592 Jun 28 '18 at 4:08
• thanks a lot, I use your method to modify my figure, but there is still some problems, pls see my upadte(need I accept your answer then open a new qustion?) – user6703592 Jun 28 '18 at 5:04
• many thanks, but the first row seems in the wrong position. – user6703592 Jun 28 '18 at 8:16
• column is one-to-one corresponding for first row and and second row, The last figure is what I want. – user6703592 Jun 28 '18 at 8:43
• is it possible to avoid use \usepackage{makecell} since my office PC can not install the extra usepackage – user6703592 Jun 28 '18 at 9:39

Maybe the following suits your needes:

\documentclass{article}
\usepackage{geometry}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{bigstrut}
\usepackage{array}
\usepackage{ragged2e}

\newcolumntype{C}[1]{>{\Centering\arraybackslash}p{#1}}
\begin{document}

\begin{table}
\setlength{\tabcolsep}{3.4pt}
\newcommand{\mystrut}{\rule[-4pt]{0pt}{10pt}}
\begin{tabular}{@{}ccC{4cm}C{1.9cm}C{1.25cm}C{1.6cm}C{2cm}@{}}
\toprule
Ticker & Types & Strikes & Up \newline Barriers & Down \newline Barriers & Up/Down \newline LevelInit & Barrier \newline Types\\
\midrule
Trade A & Vanilla \mystrut
&  \multirow{3}{\hsize}{\Centering max(1.05*S+4, 1.10*S)  min(1.05*S+8, 1.10*S+4)  min(1.05*S+4, 1.10*S)  max(1.05*S+4, 1.10*S)} &
\multirow{4}{*}{1.1*S} &
\multirow{4}{*}{0.9*S} &
\multirow{8}{\hsize}{\Centering 1.2*TS/ 0.8*TS} &
\multirow{8}{\hsize}{\Centering Continuous/ Out}\\
\cmidrule(r){1-2}
Trade B & Digital \mystrut & \\
\cmidrule(r){1-2}
Trade C & Vanilla \mystrut & \\
\cmidrule(r){1-5}
Trade D & Vanilla \mystrut
&  \multirow{3}{\hsize}{\Centering S \newline 1.05*S  \newline min(1.05*S+4, 1.10*S) max(1.05*S+4, 1.10*S)} &
\multirow{4}{\hsize}{\Centering x*S  Multiplier x moving as x-variable} &
\multirow{4}{*}{0.8*S} \\
\cmidrule(r){1-2}
Trade E & Digital \mystrut & \\
\cmidrule(r){1-2}
Trade F & Quadratic \mystrut & \\
\bottomrule

\end{tabular}
\end{table}

%                           & x*S,                          & \multirow{4}{*}{0}      &                                               &  \\
%    1.05*S                    &                   & & &           \\
%    min(1.05*S+4, 1.10*S)     &                      & & &           \\
%    max(1.05*S+4, 1.10*S)     &                     & & &   \\

\end{document}


I have removed the nested tabulars. For additional spacing in the first columns, I have used a strut, as rcommended in the multirow manual.