使用 multicol 包进行逐项列举

使用 multicol 包进行逐项列举

我正在为学生做作业,我想水平列出作业列表。但是当我尝试这样做时,其中一个项目会略高于其他项目,而项目内容会略低于其他项目。

我附上了 MWE 和相应的结果。如能得到任何帮助我将不胜感激。

韩国

\documentclass[12pt]{article}

\newenvironment{problem}[2][Problem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol} % to insert columns
    \setlength{\columnsep}{5pt}
\usepackage{hyperref}
    \hypersetup{
        colorlinks=true,
        linkcolor=cyan,
        filecolor=magenta,      
        urlcolor=blue,
        }
\usepackage{parskip} % For no indentation and a bit of space in paragraphs

% to format enumerate to letters
\usepackage{enumitem}


\begin{document}

\title{Problem Set 2}
\author{Ruben Perez Sanz}
\date{7 September, 2020}
\maketitle


\begin{problem}{7}
    Calculate the following determinants
    \begin{multicols}{4}
        \begin{enumerate}[label=(\alph*)]
            \item $\left|\begin{matrix} 3 & 0 \\  2 & 6 \end{matrix}\right|$
            \item $\left|\begin{matrix} a & a \\  b & b \end{matrix}\right|$
            \item $\left|\begin{matrix} a+b & a-b \\  a-b & a+b \end{matrix}\right|$
            \item $\left|\begin{matrix} 3^t & 2^t \\  3^{t-1} & 2^{t-1} \end{matrix}\right|$
        \end{enumerate}
    \end{multicols}
\end{problem}


\end{document}

在此处输入图片描述

答案1

这是一个不使用multicols环境的解决方案。相反,它使用enumitem选项加载包inline并使用enumerate*环境。该解决方案还利用包的机制amsthm来简化环境的定义problem

在此处输入图片描述

\documentclass[12pt]{article}
%% (I've simplified the preamble code to the bare minimum)
\usepackage{amsmath,amssymb,amsthm}
\theoremstyle{definition} % upright-lettering style
\newtheorem{problem}{Problem}

\usepackage[inline]{enumitem} % <-- note the option 'inline'

\begin{document}

\setcounter{problem}{6} % adjust as needed
\begin{problem}
Calculate the following determinants.

\begin{enumerate*}[label=(\alph*)]
\item $\begin{vmatrix} 3 & 0 \\ 2 & 6 \end{vmatrix}$ 
\hspace*{1cm} %  choose a suitable amount of horizontal whitespace
\item $\begin{vmatrix} a & a \\ b & b \end{vmatrix}$ 
\hspace*{1cm}
\item $\begin{vmatrix} a+b & a-b \\ a-b & a+b \end{vmatrix}$ 
\hspace*{1cm}
\item $\begin{vmatrix} 3^t & 2^t \\ 3^{t-1} & 2^{t-1} \end{vmatrix}$
\end{enumerate*}
\end{problem}

\end{document}

答案2

另一个快速解决方案可能是:

  1. 使用\usepackage[margin=1in]{geometry}
  2. enumitem排队\usepackage[inline]{enumitem};
  3. 正确写出矩阵\begin{vmatrix}....\end{vmatrix}

\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\newenvironment{problem}[2][Problem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol} % to insert columns
    \setlength{\columnsep}{5pt}
\usepackage{hyperref}
    \hypersetup{
        colorlinks=true,
        linkcolor=cyan,
        filecolor=magenta,      
        urlcolor=blue,
        }
\usepackage{parskip} % For no indentation and a bit of space in paragraphs

% to format enumerate to letters in line
\usepackage[inline]{enumitem}
\begin{document}

\title{Problem Set 2}
\author{Ruben Perez Sanz}
\date{7 September, 2020}
\maketitle


\begin{problem}{7}
    Calculate the following determinants:
    \begin{multicols}{4}
        \begin{enumerate}[label=(\alph*)]
            \item $\begin{vmatrix} 3 & 0 \\  2 & 6 \end{vmatrix}$
            \item $\begin{vmatrix} a & a \\  b & b \end{vmatrix}$
            \item $\begin{vmatrix} a+b & a-b \\  a-b & a+b \end{vmatrix}$
            \item $\begin{vmatrix} 3^t & 2^t \\  3^{t-1} & 2^{t-1} \end{vmatrix}$
        \end{enumerate}
    \end{multicols}
\end{problem}


\end{document}

在此处输入图片描述

答案3

您还可以使用调整框包裹。

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm,adjustbox}
\usepackage{multicol}
\begin{document}
With top alignment
\begin{multicols}{3}
    \begin{enumerate}
        \item\adjustbox{valign=t}{$\begin{vmatrix}a & b \\c & d\end{vmatrix}$}
        \item\adjustbox{valign=t}{$\begin{vmatrix}a & b \\c & d\end{vmatrix}$}
        \item\adjustbox{valign=t}{$\begin{vmatrix}a & b \\c & d\end{vmatrix}$}
    \end{enumerate}
\end{multicols}
With middle alignment
\begin{multicols}{3}
\begin{enumerate}
        \item\adjustbox{valign=m}{$\begin{vmatrix}a & b \\c & d\end{vmatrix}$}
        \item\adjustbox{valign=m}{$\begin{vmatrix}a & b \\c & d\end{vmatrix}$}
        \item\adjustbox{valign=m}{$\begin{vmatrix}a & b \\c & d\end{vmatrix}$}
    \end{enumerate}
\end{multicols}
\end{document}

相关内容