Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to illustrate how to solve a system of linear equations but I don't come along with the different approaches to position the equations. They are shifted at some slides, e.g. if an arrow is displayed or even if some variables are only colored!

Here's my simple but not so minimal looking example:

\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}
share|improve this question

2 Answers 2

In order to avoid the wobbling, you need to ensure that the content of each slide matchs with the others, and maintain a similar structure across the slides.

The horizontal wobbling is due to the fact that you are using a different number of alignment columns in the alignat. So adjusting those to all use the same number and adding a few \phantom fixes the problem.

The vertical wobbling can also be fixed by putting an empty tikxpicture:

  \begin{tikzpicture}
  \end{tikzpicture}  

Also, I would highly recommend that you eliminate the \ that you have manually placed to add additional spacing.

\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}

As suggested by Werner, an alternate solution to avoid having to include the \phantom{\tikz{\node (n1){};}} is to enclose the actual nodes in an \rlap as follows:

  \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*}
share|improve this answer
    
See my (deleted) answer to avoid defining unnecessary tikz nodes in a \phantom. Use \rlap instead, if you want to. –  Werner Nov 16 '11 at 22:29
    
@Werner: Have included \rlap as well. Also borrowed some text from yours -- hope you don't mind. –  Peter Grill Nov 16 '11 at 23:00
    
No problem - you had virtually the same solution. –  Werner Nov 16 '11 at 23:01
    
Great, thank you! –  Sibylle Nov 18 '11 at 11:55

A non-Tikz solution to building a system of linear equations a piece at a time (matrix form, but still generally applicable):

enter image description here

enter image description here

enter image description here

The code can probably be tightened up---I originally wrote it in 2004 (or possibly earlier), when I was just getting started on 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}
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.