线性方程组摆动

线性方程组摆动

我尝试说明如何求解线性方程组,但我不知道如何定位方程。它们在某些幻灯片上发生了移动,例如如果显示箭头,或者某些变量仅带有颜色!

下面是我的简单但看起来并不那么简约的示例:

\documentclass[dvipsnames,mathserif]{beamer}

\usepackage{tikz}
\RequirePackage{color}
\usepackage{amsmath}

\newcommand{\ma}[1]{\textcolor[named]{Magenta}{#1}}
\newcommand{\cy}[1]{\textcolor[named]{Cyan}{#1}}

\begin{document}

\tikzstyle{every picture}+=[remember picture]

%%%%%%%% Folie  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
  \frametitle{LGS (without anything)}
  %=========================== 
  \begin{alignat*}{4}
    x_1\ &+\ 2x_2\ &          &+\ x_4\ &=\ 1\\
    x_1\ &+\ 2x_2\ &+\ 2x_3\ &+\ 3x_4\\
&=\ 5\\
    2x_1\\
&+\ 4x_2\\
&          &+\ 3x_4\\
&=\ 5\\
            &           &  3x_3\ &+\ 2x_4\\
&=\ 3
  \end{alignat*}


}

\frame
{
  \frametitle{LGS (with arrow)}
  %===========================
  \begin{alignat*}{5}
          &          &  3x_3\ &+\ 2x_4\ &=\ 3 &\tikz{\node (n1){};} \\
    x_1\ &+\ 2x_2\ &+\ 2x_3\ &+\ 3x_4\\
&=\ 5 \\
    2x_1\ &+\ 4x_2\\
 &          &+\ 3x_4\\
&=\ 5 \\
     x_1\ &+\ 2x_2\ &+\ x_4\ &=\ 1       &\tikz{\node (n2){};}
  \end{alignat*}

  \begin{tikzpicture}[overlay]
    \path<2>[blue,<->,thick] (n1.east) edge [out= 330, in= 30] (n2.east);
  \end{tikzpicture}  
}

%%%%%%%% Folie  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
  \frametitle{LGS (colored variables and with arrow)}
  %===========================
  %\normalsize
  \begin{alignat*}{5}
              &               &\cy{3x_3}\ &+\ \cy{2x_4}\ &=\ \cy{3} &\tikz{\node (n3){};} \\
    x_1\ &+\ 2x_2\ &+\ 2x_3\\
&+\ 3x_4\\
  &=\ 5 \\
    2x_1\\
 &+\ 4x_2\\
   &            &+\ 3x_4\\
  &=\ 5 \\
    \ma{x_1}\ &+\ \ma{2x_2}\ &            &+\ \ma{x_4}\ &=\ \ma{1} &\tikz{\node (n4){};}
  \end{alignat*}

  \begin{tikzpicture}[overlay]
    \draw[blue,<->,thick] (n3.east) to [out= 330, in= 30] (n4.east);
  \end{tikzpicture}
}

%%%%%%%% Folie  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
  \frametitle{LGS (colored variables)}
  %===========================


  \begin{alignat*}{4}
    \ma{x_1}\ &+\ \ma{2x_2}\ &              &+\ \ma{x_4}\ &=\ \ma{1}\\
        x_1\ &+\ 2x_2\\
  &+\ 2x_3\\
  &+\ 3x_4\\
  &=\ 5 \\
       2x_1\ &+\ 4x_2\\
  &              &+\ 3x_4\\
  &=\ 5 \\
              &              &\cy{3x_3}\\
&+\ \cy{2x_4}\ &=\ \cy{3} \\ 
  \end{alignat*}

}

\frame
{
  \frametitle{LGS (again without anything)}
  %=========================== 
  \begin{alignat*}{4}
    x_1\\
&+\ 2x_2\\
   &          &+\ x_4\\
 &=\ 1\\
    x_1\\
&+\ 2x_2\\
   &+\ 2x_3\ &+\ 3x_4\\
&=\ 5\\
    2x_1\ &+\ 4x_2\\
   &          &+\ 3x_4\\
&=\ 5\\
            &               &  3x_3\ &+\ 2x_4\\
&=\ 3
  \end{alignat*}


}

\end{document}

答案1

为了避免摇摆不定,你需要确保每张幻灯片的内容与其他幻灯片相匹配,并在幻灯片之间保持相似的结构。

水平摇摆不定这是因为您在 中使用的对齐列数不同alignat。因此,调整所有对齐列以使用相同的数字并添加一些\phantom即可解决问题。

垂直摇摆不定也可以通过放置一个空的来修复tikxpicture

  \begin{tikzpicture}
  \end{tikzpicture}  

另外,我会高度建议您消除\手动放置的以添加额外间距。

\documentclass[dvipsnames,mathserif]{beamer}

\usepackage{tikz}
\RequirePackage{color}
\usepackage{amsmath}

\newcommand{\ma}[1]{\textcolor[named]{Magenta}{#1}}
\newcommand{\cy}[1]{\textcolor[named]{Cyan}{#1}}

\begin{document}

\tikzstyle{every picture}+=[remember picture]

%%%%%%%% Folie  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
  \frametitle{LGS (without anything)}
  %=========================== 
  \begin{alignat*}{5}
    x_1\\
&+\ 2x_2\   &          &+\ \phantom{3}x_4\\
 &=\ 1 & \phantom{\tikz{\node (m1){};}}\\
    x_1\\
&+\ 2x_2\   &+\ 2x_3\  &+\ 3x_4\\
&=\ 5\\
    2x_1\   &+\ 4x_2\   &          &+\ 3x_4\\
&=\ 5\\
            &           &  3x_3\   &+\ 2x_4\\
&=\ 3
  \end{alignat*}
  \begin{tikzpicture}
  \end{tikzpicture}  
}

\frame
{
  \frametitle{LGS (with arrow)}
  %===========================
  \begin{alignat*}{5}
          &          &  3x_3\   &+\ 2x_4\   &=\ 3 &\tikz{\node (n1){};} \\
    x_1\  &+\ 2x_2\  &+\ 2x_3\  &+\ 3x_4\   &=\ 5 \\
    2x_1\ &+\ 4x_2\  &          &+\ 3x_4\   &=\ 5 \\
     x_1\ &+\ 2x_2\  &          &+\ \phantom{3}x_4\\
&=\ 1 &\tikz{\node (n2){};}
  \end{alignat*}
  %
  \begin{tikzpicture}[overlay]
    \path<2>[blue,<->,thick] (n1.east) edge [out= 330, in= 30] (n2.east);
  \end{tikzpicture}  
}

%%%%%%%% Folie  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
  \frametitle{LGS (colored variables and with arrow)}
  %===========================
  %\normalsize
  \begin{alignat*}{5}
              &               &\cy{3x_3}\  &+\ \cy{2x_4}\ &=\ \cy{3} &\tikz{\node (n3){};} \\
    x_1\\
  &+\ 2x_2\\
   &+\ 2x_3\\
&+\ 3x_4\\
  &=\ 5 \\
    2x_1\\
 &+\ 4x_2\\
   &            &+\ 3x_4\\
  &=\ 5 \\
    \ma{x_1}\ &+\ \ma{2x_2}\  &            &+\ \phantom{3}\ma{x_4}\  &=\ \ma{1} &\tikz{\node (n4){};}
  \end{alignat*}
  %
  \begin{tikzpicture}[overlay]
    \draw[blue,<->,thick] (n3.east) to [out= 330, in= 30] (n4.east);
  \end{tikzpicture}
}

%%%%%%%% Folie  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
  \frametitle{LGS (colored variables)}
  %===========================
  \begin{alignat*}{5}
    \ma{x_1}\ &+\ \ma{2x_2}\ &              &+\ \ma{\phantom{3}x_4}\  {}&=\ \ma{1}&\phantom{\tikz{\node (m2){};}}\\
        x_1\  &+\ 2x_2\\
  &+\ 2x_3\\
  &+\ 3x_4\\
             &=\ 5 \\
       2x_1\  &+\ 4x_2\\
  &              &+\ 3x_4\\
             &=\ 5 \\
              &              &\cy{3x_3}\\
&+\ \cy{2x_4}\\
        &=\ \cy{3}
  \end{alignat*}
  \begin{tikzpicture}
  \end{tikzpicture}  
}

\frame
{
  \frametitle{LGS (again without anything)}
  %=========================== 
  \begin{alignat*}{5}
    x_1\\
&+\ 2x_2\\
   &          &+\ \phantom{3}x_4\\
 &=\ 1&\phantom{\tikz{\node (m3){};}}\\
    x_1\\
&+\ 2x_2\\
   &+\ 2x_3\  &+\ 3x_4\\
&=\ 5\\
    2x_1\   &+\ 4x_2\\
   &          &+\ 3x_4\\
&=\ 5\\
            &               &  3x_3\   &+\ 2x_4\\
&=\ 3
  \end{alignat*}
  \begin{tikzpicture}
  \end{tikzpicture}  
}
\end{document}

按照 Werner 的建议,避免包含的另一种解决方案\phantom{\tikz{\node (n1){};}}是将实际节点括在里面,\rlap如下所示:

  \begin{alignat*}{4}
              &               &\cy{3x_3}\  &+\ \cy{2x_4}\ &=\ \cy{3} \rlap{\quad \tikz{\node (n3){};}} \\
    x_1\\
  &+\ 2x_2\\
   &+\ 2x_3\\
&+\ 3x_4\\
  &=\ 5 \\
    2x_1\\
 &+\ 4x_2\\
   &            &+\ 3x_4\\
  &=\ 5 \\
    \ma{x_1}\ &+\ \ma{2x_2}\  &            &+\ \ma{x_4}\  &=\ \ma{1} \rlap{\quad \tikz{\node (n4){};}}
  \end{alignat*}

答案2

一个非 Tikz 解决方案,用于一次构建一个线性方程组(矩阵形式,但仍然普遍适用):

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

代码可能需要更严格一些---我最初是在 2004 年(或可能更早)编写的,当时我刚刚开始使用 Beamer。

\documentclass{beamer}
\usepackage{amsmath}

\begin{document}

\frame{
  \frametitle{Filling out the matrix equation}
  \begin{enumerate}[<+-| alert@+>]
  \item Populate the unknowns vector with the list of unknown variables.
  \item Populate the right-hand side vector with the right-hand sides
    of the equations.
  \item Populate each row of the coefficient matrix with coefficients
    from the left-hand side of the equations.
  \end{enumerate}
  \begin{displaymath}
    \left[ \begin{array}{rrrrrr}
        \onslide<3-> 1 & 1 & -1 & -1 & 0 & -1 \\
        \onslide<4-> 0 & -9 & 1 & 4 & 0 & 7 \\
        \onslide<5-> 0 & 0 & 1 & 1 & -1 & 0 \\
        \onslide<6-> 0 & 0 & 0 & -3 & 2 & 0 \\
        \onslide<7-> 0 & 0 & 0 & 0 & 1 & 1 \\
        \onslide<8-> 0 & 0 & 0 & 0 & 0 & -4 \\
      \end{array} \onslide<1-> \right]
    \onslide<1-> \left\{ \begin{array}{c}
        T_A \onslide<1-> \\
        T_B \onslide<1-> \\
        T_C \onslide<1-> \\
        T_D \onslide<1-> \\
        T_E \onslide<1-> \\
        T_F \onslide<1-> \\
      \end{array} \right\} =
    \onslide<1-> \left\{ \begin{array}{r}
        \onslide<2-> P_1 \\
        -5P_1\onslide<2->  \\
        P_2 \onslide<2-> \\
        -P_2 \onslide<2-> \\
        P_3 \onslide<2-> \\
        -P_3 \onslide<2-> \\
      \end{array} \onslide<1-> \right\}
  \end{displaymath}
}

相关内容