过去,我曾使用 array 包来创建表格枚举列表,如下例所示。
\documentclass[11pt]{article}
%%%% Packages and options
\usepackage{mathtools} % extension of amsmath and will load amsmath
\usepackage[letterpaper, hmargin={0.6in, 0.6in}]{geometry}
\setlength{\parindent}{0pt}
%%%% for multiple choice tables
\newcounter{mc}
\newcommand*{\AddLabel}{%
\stepcounter{mc}%
\makebox[1.75em][l]{(\Alph{mc})}~%
}%
\usepackage{array}
\newcolumntype{P}[1]{>{\AddLabel}p{#1}<{}}
\setlength{\tabcolsep}{0pt} % Default value: 6pt
%%%% Begin document
\begin{document}
\noindent $\int xe^{x^2}\,dx =$ \\
\noindent
\setcounter{mc}{0}
\begin{tabular}[t]{*{5}{P{0.2\linewidth}}}
$\frac{1}{2}e^{x^2} + C$
& $e^{x^2} + C$
& $xe^{x^2} + C$
& $\frac{1}{2}e^{2x} + C$
& $e^{2x} + C$
\end{tabular}
\end{document}
我想知道是否有办法使用 tabularray 包实现相同的结果。谢谢!
答案1
尝试
\documentclass[11pt]{article}
\usepackage[letterpaper, hmargin={0.6in, 0.6in}]{geometry}
%%%% Packages and options
\usepackage{mathtools} % extension of amsmath and will load amsmath
\usepackage{tabularray} % <---
\UseTblrLibrary{counter} % <---
\newcounter{mc}
\newcommand*{\AddLabel}{\stepcounter{mc}\Alph{mc})} % <---
\setlength{\parindent}{0pt}
%%%% Begin document
\begin{document}
$\displaystyle\int xe^{x^2}\,dx =$ \\
\begin{tblr}{colspec={@{} *{5}{>{\AddLabel\quad}X[l]} @{}} }
$\frac{1}{2}e^{x^2} + C$
& $e^{x^2} + C$
& $xe^{x^2} + C$
& $\frac{1}{2}e^{2x} + C$
& $e^{2x} + C$
\end{tblr}
\end{document}