我正在尝试在表格中显示多项选择题以及说明和百分比。这是我的尝试:
\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*}
但情况看起来不太好:
有没有更好的方法?我必须为每种问题类型显示两个多项选择题。
编辑:
接受的答案的代码运行良好,但我收到了这个错误:
如何调整表格大小以使其适合一页?
答案1
\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}
如果您希望答案根据问题缩进,请替换leftmargin=*
为leftmargin=30pt
或您选择的其他长度。