通过 minipage 将多个矩阵并排放置

通过 minipage 将多个矩阵并排放置

我正在尝试将两个矩阵并排对齐。我正在使用 minipage,但它不起作用。这是我的代码

\begin{frame}{Addition and Subtraction}
\begin{itemize}
\item Addition and subtraction are element-wise; sizes must
match (unless one is a scalar):

\begin{minipage}[t]{0.1\linewidth}
\begin{flushleft}
\tiny{
\begin{align*}
&\begin{bmatrix} 12 & 3 & 32 &-11 \\[0.3em]\end{bmatrix}\\
+&\begin{bmatrix} 2 & 11 & -30 &32 \\[0.3em]\end{bmatrix}\\
= 
& \begin{bmatrix} 14 & 14 & 2 &21 \\[0.3em]\end{bmatrix}
\end{align*}}
\end{flushleft}
\end{minipage}

\begin{minipage}[t]{0.1\linewidth}
\begin{flushright}
\tiny{
\[
\begin{bmatrix}
12 \\[0.3em]
1 \\[0.3em]
-10 \\[0.3em]
0 \\[0.3em]
\end{bmatrix}
-
\begin{bmatrix}
3 \\[0.3em]
-1 \\[0.3em]
13 \\[0.3em]
33 \\[0.3em]
\end{bmatrix}
=
\begin{bmatrix}
9 \\[0.3em]
2 \\[0.3em]
-23 \\[0.3em]
-33 \\[0.3em]
\end{bmatrix}
\]
}
\end{flushright}
\end{minipage}

\item The following would give an error

{\scriptsize{\fontseries{b}\texttt{
\textcolor{blue}{>> c = row + column}}}}
\item Use the transpose to make sizes compatible

{\scriptsize{\fontseries{b}\texttt{
\textcolor{blue}{>> c = row\textquotesingle+ column\\\
>> c = row + column\textquotesingle}}}}

\item Can sum up or multiply elements of vector

{\scriptsize{\fontseries{b}\texttt{
\textcolor{blue}{>> s=sum(row);\\\
>> p=prod(row);}}}}
\end{itemize}
\end{frame}

在此处输入图片描述

答案1

要消除两个环境之间的换行符minipage,请删除当前位于它们之间的空行。请记住:当 TeX 处于“文本模式”时,空行充当段落分隔符。

您可能还想稍微简化和精简一下代码。例如,我认为没有必要将数学材料的字体大小设置得“很小”。以下示例提供了一些具体建议。

在此处输入图片描述

\documentclass{beamer}
\usepackage{textcomp} % for '\textquotesingle' macro
\begin{document}
\begin{frame}{Addition and Subtraction}
\begin{itemize}
\item Addition and subtraction are element-wise; sizes must
match (unless one is a scalar):

\begin{minipage}{0.45\linewidth}
\renewcommand\arraystretch{1.6}
\[ \begin{array}{rrrr}
 \Big[\,12 & 3 & 32 & -11\,\Big] \\ 
{+}\Big[\,\phantom{0}2 & \phantom{-}11 & -30 & 32 \,\Big] \\
{=}\Big[\,14 & 14 & 2 & 21\, \Big] \\
\end{array} \]
\end{minipage}
\hspace*{\fill}
\begin{minipage}{0.45\linewidth}
\renewcommand\arraystretch{1.15}
\[
\begin{bmatrix}  12 \\ 1 \\ -10 \\ 0  \end{bmatrix}
-
\begin{bmatrix} 3 \\ -1 \\ 13 \\ 33 \end{bmatrix}
=
\begin{bmatrix} 9 \\ 2 \\ -23 \\ -33 \end{bmatrix}
\]
\end{minipage}

\item The following would give an error

{\scriptsize{\fontseries{b}\texttt{
\textcolor{blue}{>> c = row + column}}}}
\item Use the transpose to make sizes compatible

{\scriptsize{\fontseries{b}\texttt{
\textcolor{blue}{>> c = row\textquotesingle+ column\\\
>> c = row + column\textquotesingle}}}}

\item Can sum up or multiply elements of vector

{\scriptsize{\fontseries{b}\texttt{
\textcolor{blue}{>> s=sum(row);\\\
>> p=prod(row);}}}}
\end{itemize}
\end{frame}
\end{document}

相关内容