投影仪中的列未对齐

投影仪中的列未对齐

我很久以来就一直面临投影机和柱子的这个问题,为什么这两列没有对齐?

\documentclass{beamer}
\usepackage{xcolor}
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usepackage{tikz}
\usetikzlibrary{matrix} 


\begin{document} 
\begin{frame}{xxxxx}
\underline{\textbf{Example}}
\begin{itemize}
\item[$\rightarrow$] Let's consider two systems of linear equations that correspond to the same coefficient matrix $\mathbf{A}$
\end{itemize}
\begin{columns}[T,onlytextwidth]

            \begin{column}{.5\textwidth}
            \begin{center}

\begin{tikzpicture}[>=stealth,thick,baseline]
   \tikzstyle{column 8}=[myblue]
 
    \matrix [matrix of math nodes,ampersand replacement=\&](A){ 
    \& 3 x_1  \&+\& 5x_2    \& -\&4x_3   \& =\&  7\\
    -\& 3 x_1 \& -\&2x_2  \& +\&4x_3   \& =\&  -1\\
     \& 6  x_1 \& +\&x_2   \& -\&8x_3    \& = \& -4\\
   };
   \end{tikzpicture}
   \end{center}
            \end{column}
            \begin{column}{.5\textwidth}
            \begin{tikzpicture}[>=stealth,thick,baseline]
   \tikzstyle{column 5}=[myblue]
 
    \matrix [matrix of math nodes,ampersand replacement=\&](A){ 
    \& 3 x_1  \&+\& 5x_2    \& -\&4x_3   \& =\&  7\\
    -\& 3 x_1 \& -\&2x_2  \& +\&4x_3   \& =\&  -1\\
     \& 6  x_1 \& +\&x_2   \& -\&8x_3    \& = \& -4\\
   };
   \end{tikzpicture}
            \end{column}
\end{columns}

\end{frame}
\end{document}

答案1

我删除了center第一列中的 -environment。现在两列完美对齐了。

\documentclass{beamer}
\usepackage{xcolor}
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usepackage{tikz}
\usetikzlibrary{matrix} 

\begin{document} 
\begin{frame}{xxxxx}
\underline{\textbf{Example}}
\begin{itemize}
\item[$\rightarrow$] Let's consider two systems of linear equations that correspond to the same coefficient matrix $\mathbf{A}$
\end{itemize}

\begin{columns}[T,onlytextwidth]
\begin{column}{.5\textwidth}
    \begin{tikzpicture}[>=stealth,thick,baseline]
       \tikzstyle{column 8}=[myblue]
        \matrix [matrix of math nodes,ampersand replacement=\&](A){ 
         \& 3 x_1  \&+\& 5x_2  \& -\&4x_3   \& =\&  7\\
        -\& 3 x_1  \& -\&2x_2  \& +\&4x_3   \& =\&  -1\\
         \& 6  x_1 \& +\&x_2   \& -\&8x_3   \& = \& -4\\
       };
   \end{tikzpicture}
\end{column}

\begin{column}{.5\textwidth}
    \begin{tikzpicture}[>=stealth,thick,baseline]
        \tikzstyle{column 5}=[myblue]
        \matrix [matrix of math nodes,ampersand replacement=\&](A){ 
         \& 3 x_1  \&+\& 5x_2 \& -\&4x_3   \& = \&  7\\
        -\& 3 x_1 \& -\&2x_2  \& +\&4x_3   \& = \&  -1\\
         \& 6  x_1 \& +\&x_2  \& -\&8x_3   \& = \& -4\\
        };
   \end{tikzpicture}
\end{column}
\end{columns}

\end{frame}
\end{document}

在此处输入图片描述

答案2

  • 您需要在这两列中插入\begin{center}...\end{center}或者最好用命令替换它们\centering,如下面的 MWE 中所做的那样。
  • 无关:
    • 您可以合并两个矩阵的tikz共同选项\tikzset
    • beamer加载xtabular,这样你就不需要再次加载
    • 在下面的 MWE 中,矩阵元素之间的空间也减少了(通过inner xsep=1pt
\documentclass{beamer}
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usepackage{tikz}
\usetikzlibrary{matrix}


\begin{document}
\begin{frame}{xxxxx}
\underline{\textbf{Example}}
    \begin{itemize}
\item[$\rightarrow$] Let's consider two systems of linear equations that correspond to the same coefficient matrix $\mathbf{A}$
\end{itemize}
\begin{columns}[T,onlytextwidth]
\tikzset{M/.style={ >=stealth,thick,baseline,
                    matrix of math nodes,
                    inner xsep=1pt, 
                    column 8/.append style =myblue,
                    ampersand replacement=\&}
        }
            \begin{column}{.49\textwidth}
            \centering
\begin{tikzpicture}[]
    \matrix (A) [M]    
    {
     \& 3 x_1  \&+\& 5x_2  \&-\& 4x_3   \&=\&   7\\
    -\& 3 x_1  \&-\& 2x_2  \&+\& 4x_3   \&=\&  -1\\
     \& 6 x_1  \&+\&  x_2  \&-\& 8x_3   \&=\&  -4\\
   };
   \end{tikzpicture}
            \end{column}
            \begin{column}{.49\textwidth}
            \centering
   \begin{tikzpicture}
    \matrix (B) [M]
    {
     \& 3 x_1  \&+\& 5x_2   \&-\& 4x_3  \&=\&   7\\
    -\& 3 x_1  \&-\& 2x_2   \&+\& 4x_3  \&=\&  -1\\
     \& 6 x_1  \&+\&  x_2   \&-\& 8x_3  \&=\&  -4\\
   };
   \end{tikzpicture}
            \end{column}
\end{columns}

\end{frame}
\end{document}

在此处输入图片描述

附註:

您可以按如下方式简化矩阵代码:

\documentclass{beamer}
\usepackage{fontspec}

\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{frame}[fragile]
\frametitle{Writing matrices in \texttt{beamer} }

\underline{\textbf{Example}}
    \begin{itemize}
\item[$\rightarrow$] Let's consider two systems of linear equations that correspond to the same coefficient matrix $\mathbf{A}$.
\end{itemize}
    \begin{columns}[T,onlytextwidth]
\tikzset{M/.style = {>=stealth,thick,baseline,
                    matrix of math nodes,
                    nodes={inner xsep=1pt, anchor=east},
                    column 4/.append style=blue,
                    }
        }
\begin{column}{.49\textwidth}
    \centering
    \begin{tikzpicture}
\matrix (A) [M]
{
    3 x_1   + & 5x_2   - & 4x_3   = &   7\\
  - 3 x_1   - & 2x_2   + & 4x_3   = &  -1\\
    6 x_1   + &  x_2   - & 8x_3   = &  -4\\
};
   \end{tikzpicture}
\end{column}
\begin{column}{.49\textwidth}
\centering
   \begin{tikzpicture}
   \centering
    \matrix (B) [M]
    {
        3 x_1   + & 5x_2   - & 4x_3   = &   7\\
      - 3 x_1   - & 2x_2   + & 4x_3   = &  -1\\
        6 x_1   + &  x_2   - & 8x_3   = &  -4\\
   };
   \end{tikzpicture}
\end{column}
    \end{columns}
\end{frame}
\end{document}

使用 XeLaTeX 编译它,得到以下结果:

在此处输入图片描述

相关内容