1

I was unable to create the following table enter image description here

Here is my MWE:

\documentclass{article}
\usepackage[english]{babel}
%\usepackage{multirow}
\usepackage{amsmath} 

\begin{document}

\begin{table}[htb!]
\centering 
\begin{tabular}{c |c|c|c|c|}
\cline{2-3}
 & \multicolumn{2}{ c| }{Figure Here} \\ \cline{2-3}
 & First entry & Second entry    \\ \cline{1-3}
\multicolumn{1}{ |c| }{First door} & $\begin{aligned}[t]\frac{\beta}{\alpha}\end{aligned}$ & $\begin{aligned}[t]\frac{\beta}{\alpha}\end{aligned}$  \\ \cline{1-3}
\multicolumn{1}{ |c| }{Second door} &  $\begin{aligned}[t]\frac{\beta}{\alpha}\end{aligned}$ & $\begin{aligned}[t]\frac{\beta}{\alpha}\end{aligned}$  \\ \cline{1-3}
\end{tabular}
\caption{Ways} 
\end{table}
\end{document} 
3
  • Also, you use the aligned environment, but don't have whatever to align, and the texts of the code doesn't correspond to the image… – Bernard Nov 26 '17 at 11:51
  • @Bernard: I used the aligned environment because I repeatedly get an error when I write $$\frac{\alpha}{\beta}$$ inside the table. – Maryà Nov 26 '17 at 11:56
  • 3
    @marya - You most definitely shouldn't use $$...$$ inside a tabular environment. Write $\displaystyle ... $ instead. – Mico Nov 26 '17 at 11:58
7

I'd like to recommend that you give the table a much more open look, mainly by (a) omitting all vertical lines and (b) using fewer, but well-spaced, horizontal lines. Your readers will certainly appreciate it -- and they will likely show their appreciation by actually taking the time to read and understance the table's contents.

enter image description here

\documentclass{article}
\usepackage{amsmath,booktabs} 
\begin{document}

\begin{table}[htb!]
\centering 
\begin{tabular}{@{}lcc@{}}
\cmidrule[\heavyrulewidth](l){2-3}
 & \multicolumn{2}{ c@{}}{Figure Triangle Here} \\ 
 \cmidrule(l){2-3}
 & First entry & Second entry    \\ 
 \midrule
First door & $\dfrac{\beta\mathstrut}{\alpha}$ & $\dfrac{\beta}{\alpha}$  \\ 
\addlinespace
Second door &  $\dfrac{\beta}{\alpha\mathstrut}$ & $\dfrac{\beta}{\alpha}$  \\ 
\bottomrule
\end{tabular}
\caption{Ways} 
\end{table}
\end{document} 

Addendum to address the OP's follow-up question: Your objective may be achieved by (a) loading the caption package and (b) replacing

 \multicolumn{2}{ c@{}}{Figure Triangle Here}

with

 \multicolumn{2}{c@{}}{
 \begin{minipage}{3.5cm}
 \centering 
 \includegraphics[width=0.5\textwidth]{triangle.jpg}
 \captionof*{figure}{Figure: Triangle}
 \end{minipage}}
3
  • I am unable to make a caption of the figure. I added \multicolumn{2}{c @{}}{\includegraphics[]{triangle.jpg}} along with graphicx package. – Maryà Nov 26 '17 at 18:14
  • 1
    @marya - I'm not sure I understand. First off, there's a table environment, not a figure environment. Second, the code already a \caption statement; did you try to add another one? Please clarify. Regarding the triangle: Did you replace the directive \multicolumn{2}{c@{}}{Figure Triangle Here} with \multicolumn{2}{c@{}}{\includegraphics[width=<some width>]{triangle.jpg}}? – Mico Nov 26 '17 at 18:21
  • Yes, I did but I want to add a caption for the figure like in the diagram shown in the question. – Maryà Nov 27 '17 at 5:11
6

This code works fine without aligned. I suggest to use the cellspace package to give cells some padding (otherwise, the fractions touch the horizontal lines), and the medium-sized fractions from nccmath – in my opinion text fractions look petty in this context. Last remark: since version 3.9 of babel, it is recommended the language option be loaded with the document class, so language-dependent packages be aware of the main language in the document.

\documentclass[english]{article}
\usepackage{babel}

\usepackage{array, cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}
\usepackage{amsmath, nccmath}

\begin{document}

\begin{table}[htb!]
\centering
\begin{tabular}{*{4}{Sc|}}
\cline{2-3}
 & \multicolumn{2}{Sc| }{Figure Here} \\ %
 \cline{2-3}
 & First entry & Second entry \\ %
 \cline{1-3}
\multicolumn{1}{ |c| }{First door} & $ \mfrac{\beta}{\alpha}$ & $ \mfrac{\beta}{\alpha} $ \\ \cline{1-3}
\multicolumn{1}{ |c| }{Second door} & $ \frac{\beta}{\alpha} $ & $ \frac{\beta}{\alpha} $ \\ %
\cline{1-3}
\end{tabular}
\caption{Ways}
\end{table}

\end{document} 

enter image description here

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.