0

I am trying to show multiple-choice questions in a table along with a description & percent. Here is my attempt:

\begin{table*}
\small
\centering
\begin{tabular}{rrr}
\toprule
 {\bf Question Type} & {\bf Percent.} & {\bf Example} \\
\midrule

Type 1 & 0.47 &\makecell{Which is not a side effect of the progestogen-only pill (POP)? \\hfill \textbf{a)} \colorbox{mygreen}{Ovarian cysts} \textbf{b)} Venous thromboembolism \ \textbf{c}) Increased risk of diabetes mellitus \textbf{d)} Ectopic pregnancy} \ \hline Type 1 & 0.47 &\makecell{Which is not a side effect of the progestogen-only pill (POP)? \\hfill \textbf{a)} \colorbox{mygreen}{Ovarian cysts} \textbf{b)} Venous thromboembolism \ \textbf{c}) Increased risk of diabetes mellitus \textbf{d)} Ectopic pregnancy} \ \bottomrule \end{tabular} \caption{} \label{tab:subject_wise} \vspace{-2ex} \end{table*}

But it's not looking good :

enter image description here

Is there a better way to do this? I have to show two multiple-choice questions per question type.

Edit:

The accepted answer's code is working well, but I am getting this error:

enter image description here

enter image description here

How to resize the table to fit it in one page?

1 Answers1

1

enter image description here

\documentclass[twocolumn]{article}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{xcolor}
\definecolor{mygreen}{RGB}{0,255,0}
\usepackage{tabularx}
\usepackage{caption}
\renewcommand{\theadfont}{\normalsize\bfseries}

\usepackage[inline]{enumitem} \newlist{tabenum}{enumerate}{1} \setlist[tabenum]{label=\alph), font=\bfseries, leftmargin=*, nosep, before=\begin{minipage}[t]{\hsize}, after=\end{minipage}}

\setlength\fboxsep{0pt} \newcommand{\correctitem}{\item[\stepcounter{tabenumi}\colorbox{mygreen}{\thetabenumi}]} \begin{document}

\begin{table*} \caption{Fine-grained evaluation per medical subject in Test and Dev set} \label{tab:subject_wise} \begin{tabularx}{\textwidth}{ccX} \toprule \thead{Question\ Type} & \thead{Percent.} & \thead{Example} \ \midrule Type 1 & 0.47 & Which is not a side effect of the progestogen-only pill (POP)? \ & & \begin{tabenum} \correctitem Ovarian cysts \item Venous thromboembolism \item Increased risk of diabetes mellitus \item Ectopic pregnancy \end{tabenum} \ \midrule Type 1 & 0.47 & Which is not a side effect of the progestogen-only pill (POP)? Ths question is a lot longer, this question is a lot longer \ & & \begin{tabenum} \correctitem Ovarian cysts \item Venous thromboembolism \item Increased risk of diabetes mellitus \item Ectopic pregnancy \end{tabenum} \ \bottomrule \end{tabularx}

\end{table*}

\end{document}


If you want the answers to be indented with respect to the question, replace leftmargin=* with leftmargin=30pt or a different length of your choice.

leandriis
  • 62,593
  • Hi, it's working, although what if my options are too long in the text? how to split them? – Aaditya Ura Jan 31 '21 at 14:03
  • Which options? The individual answers/items? What does "too long in text mean" and what does "split them" refer to? Linebreaks in long items will occur automatically while the overall width of the table will adapt to the width of the text. – leandriis Jan 31 '21 at 14:05
  • Please check the edit in question. – Aaditya Ura Jan 31 '21 at 15:29
  • @AadityaUra: I assume, the page only contains the table. Is that correct? You mention wanting to fit the table onto the page. Does it have to fito onto a single page or are you willing to let it occupy multiple pages? – leandriis Jan 31 '21 at 18:19
  • Hi, I want to shrink the size to fit it properly in the page and yes the page contains only table. – Aaditya Ura Feb 01 '21 at 10:38
  • Unless you shrik the font size quote drastically or switch to the different enumerate style I suggested in a previous comment, fitting the whole table onto a single page will be hardly possible. – leandriis Feb 01 '21 at 10:41