如何逐步突出显示/揭示/通过路径连接与文本混合的数学公式的各个部分?

如何逐步突出显示/揭示/通过路径连接与文本混合的数学公式的各个部分?

我编写了以下代码,它可以工作,并且大致可以完成任务。但它存在许多缺陷,我认为它很丑陋,并希望得到一些关于如何正确完成相同任务的建议!

\documentclass{beamer}
\usepackage{etex}
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsmath, amssymb, ifthen, calc}
\hypersetup{pdfencoding=utf8}
\usepackage{pgfplots, tikz, xargs}
\usetikzlibrary{arrows, arrows.meta, bending, fadings, matrix, positioning, shadows, shadows.blur, shapes, shapes.misc, tikzmark}
\usetikzlibrary{overlay-beamer-styles}
\usetikzlibrary{matrix, fit, backgrounds, patterns, decorations.pathreplacing}


\begin{document}

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


\begin{frame}[fragile]
\textbf{\Large Exemple 1 (simple)}

\tikzset{%
    mes styles/.style={},
    mes styles 1/.style={fill=white},
    mes styles 2/.style={fill=green!20}}

\only<2-3>{\tikzset{mes styles/.style={mes styles 2}}}


\begin{tikzpicture}
\node[anchor=west] (R) at (0,0) {Résoudre} ;
\matrix[matrix of math nodes, nodes={minimum width=width("$-1$"), minimum height=1.5em}, align=left, column sep=-\pgflinewidth, row sep=-\pgflinewidth] at (5.5, -.5ex) (S1) {
    |[mes styles]| $2$ & $x$ & $+$ &   & $y$ & $-$ & $5$ & $=$ & $0$ & $L_1$\\
    |[mes styles]| \alt<3>{\color{red}{$\!\!-1\!\!$}}{$\!-\!$} & $x$ & $+$ & $2$ & $y$ & $-$ & $8$ & $=$ & $0$ & $L_2$\\ % How to avoid moves (question related to node size)
} ;
\draw[decorate, decoration={brace, mirror, amplitude=5pt}] (S1-1-1.north west) -- (S1-2-1.south west) ;
\fill<4>[red, opacity=.2] (S1-2-1.south west) rectangle (S1-2-9.north east) ;

\uncover<4-6>{
    \node[anchor=west] at (0, -2) {d'où} ;
    \matrix[matrix of math nodes, nodes={minimum size=width("$-2$"), minimum height=1.5em}, ampersand replacement=\&, row 3/.style={visible on=<5->}, 
    below=of S1.south east, anchor=north east, align=left, yshift=1cm] (S2) {
        $\phantom{-}2$ \& $x$ \& $+$ \&   \& $y$ \& $-$ \& $5$ \& $=$ \& $0$ \& $L_1$\\ % Why matrix of math nodes are not effective ? I need to add $...$
        \alt<4>{\color{red}{$-2$}}{$-2$} \& $x$ \& $+$ \& $4$ \& $y$ \& $-$ \& $16$ \& $=$ \& $0$ \& $\color{red}2\color{black}L_2$\\
        $\hphantom{-}0$ \& $x$ \& $+$ \& $5$ \& $y$ \& $-$ \& $21$ \& $=$ \& $0$ \& \rlap{$L_1+2L_2$} \\
    } ;
    \draw[decorate, decoration={brace, mirror, amplitude=5pt}] (S2-1-1.north west) -- (S2-2-1.south west) ;
    \draw<5-9> (S2-3-1.north west) -- (S2-3-9.north east) ;
    \uncover<5>{
        \fill[green, opacity=.2]   (S2-1-1.north west) rectangle (S2-3-2.south east) ; % Why different nodes heights (ok for the lower part of y, though) ?
        \fill[cyan, opacity=.2] (S2-1-3.north west) rectangle (S2-3-5.south east) ;    % I tried to set the height without success
        \fill[blue, opacity=.2]  (S2-1-6.north west) rectangle (S2-3-7.south east) ;   % Why the colored blocks are overlapping by default ?
        \fill[orange, opacity=.2] (S2-1-9.north west) rectangle (S2-3-9.south east) ;  % 
    }
}
\fill<4>[red, opacity=.2] (S2-2-1.south west) rectangle (S2-2-9.north east) ;
\draw<4>[line width=4pt, red, -stealth] (S1-2-9.east) to [controls=+(-10:1) and +(0:1)] node[right] {$\pmb{\times 2}$} (S2-2-9.east) ; % How to use a transparency group to connect the two rectangular zone with a nice arrow ? I mean, how to blend it with various \uncover not happening all at the same moment ?

\uncover<7-10>{
    \matrix[matrix of math nodes, nodes={minimum size=width("$-2$"), minimum height=1.5em}, ampersand replacement=\&, 
    below=of S1.south east, anchor=north east, align=left, xshift=5pt, yshift=1.3cm] (S3) {
        \hphantom{-0} \& \hphantom{x} \& \hphantom{+} \& $5$ \& $y$ \& $-$ \& $21$ \& $=$ \& $0$ \& \rlap{$L_1+2L_2$}\hphantom{$L_1$} \\
    } ;
} ;

\uncover<7-11>{
    \matrix[matrix of math nodes, nodes={minimum size=width("$-2$"), minimum height=1.5em}, ampersand replacement=\&, 
    below=of S3.south east, anchor=north east, align=left, xshift=5pt, yshift=1.5cm] (S4) {
        |[visible on=<11>]| $x$ \& |[visible on=<11>]| $=$ \& |[visible on=<11>]| $\dfrac25$ \& \hphantom{5} \& |[visible on=<10>]| et \& \hphantom{-} \& $y$ \& $=$ \& $\dfrac{21}5$ \& \hphantom{$L_1$} \\
    } ;
} ;

\uncover<10>{
    \node[anchor=west] at (0,-2.8) (S5) {
        $2x+\dfrac{21}5-5=0$ d'où $2x+\dfrac{21}5-\dfrac{25}5=0$ d'où $2x=\dfrac45$ d'où $x=\dfrac25$.
    } ;
} ;

\uncover<12>{
    \node[] at (5.5,-2) {% How to position this text properly and relatively to other elements ?
        Ce système a pour solution $x=\dfrac25$ et $y=\dfrac{21}5$.
    } ;
} ;
\end{tikzpicture}


\pause

\begin{enumerate}
    \small
    \item On remarque qu'éliminer $x$ se fera simplement en multipliant $L_2$ par \tikzmarknode[minimum height=1em, inner sep=1pt, fill=green!20, fill on=<2-3>]{R3}{$2$}
    et en additionnant $L_1$ et $L_2$ : \pause
    le coefficient de $x$ dans $L_2$, qui vaut initialement \tikzmarknode[minimum height=1em, inner sep=1pt, fill=green!20, fill on=<3>, text=red, text on=<3>]{R4}{$-1$}, \pause
    passera alors à \tikzmarknode[minimum height=1em, inner sep=1pt, fill=red!20, fill on=<4>, text=red, text on=<4>]{R5}{$-2$}, \pause
    ce qui par sommation avec $L_1$ permettra d'éliminer l'inconnue $x$.\pause
    \item On obtient alors une équation à une inconnue facile à résoudre : $5y-21=0$ \pause d'où $5y=21$ d'où $y=\dfrac{21}5$.\pause
    \item On remplace alors $y$ par sa valeur dans $L_1$ ou $L_2$, au choix. \pause Comme $y$ figure seul dans $L_1$, sans coefficient, on choisit $L_1$.

\end{enumerate}
\end{frame}


\end{document}

它呈现为: 在此处输入图片描述

以下是我遇到的问题:

  • 我无法修复节点大小,因此存在一些不适当的“移动”(例如它是一个由四个部分组成的矩形(英文:花括号)和一些大小不同的彩色矩形(例如,因为 y 的下部)。
  • 数学节点矩阵在 tikzpicture 环境中不起作用?
  • 为什么我的彩色矩形有点重叠?
  • 如何使用透明组以漂亮的箭头连接两个节点(如何将其与不同时发生的各种 \uncover 混合)?
  • 如何正确对齐多个矩阵以及矩阵内部的元素?
  • 如何减少标量和未知量之间的空间?

提前感谢任何帮助或建议!

答案1

回答我能理解的问题:

  • 用于alt=<3>{text=red}{}将第三张幻灯片上的文本变为红色。
  • mathmatrix of math nodes杀死align=left
  • 重叠来自outer sep节点的 s。
  • 再次,使用 egalt=<5>{opacity=0.2}{opacity=0}代替所有这些\uncover等等命令。
  • 如果你的意思是填充的框不均匀:可以通过使用矩阵的边界而不是节点来解决,例如

    \fill[green] (S2-1-1.west|-S2.north) 矩形 (S2-3-2.east|-S2.south) ;

最后一项我不明白。结果如下:

\documentclass{beamer}
\usepackage{etex}
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsmath, amssymb, ifthen, calc}
\hypersetup{pdfencoding=utf8}
\usepackage{pgfplots, tikz, xargs}
\usetikzlibrary{arrows, arrows.meta, bending, fadings, matrix, positioning, shadows, shadows.blur, shapes, shapes.misc, tikzmark}
\usetikzlibrary{overlay-beamer-styles}
\usetikzlibrary{matrix, fit, backgrounds, patterns, decorations.pathreplacing}


\begin{document}

\tikzset{every picture/.append style={remember picture}}


\begin{frame}[fragile]
\textbf{\Large Exemple 1 (simple)}

\tikzset{%
    mes styles/.style={},
    mes styles 1/.style={fill=white},
    mes styles 2/.style={fill=green!20}}

\only<2-3>{\tikzset{mes styles/.style={mes styles 2}}}


\begin{tikzpicture}
\node[anchor=west] (R) at (0,0) {Résoudre} ;
\matrix[matrix of nodes, cells={nodes={minimum width=width("$-1$"), minimum height=1.5em}}, 
align=left, %<-undoes math in matrix of math nodes 
column sep=0pt,
 row sep=-\pgflinewidth] at (5.5, -.5ex) (S1) {
    |[mes styles]| $2$ & $x$ & $+$ &   & $y$ & $-$ & $5$ & $=$ & $0$ & $L_1$\\
    |[mes styles,alt=<3>{text=red}{}]| $\!-\!$ & $x$ & $+$ & $2$ & $y$ & $-$ & $8$ & $=$ & $0$ & $L_2$\\ % How to avoid moves (question related to node size)
} ;
\draw[decorate, decoration={brace, mirror, amplitude=5pt}] (S1-1-1.north west) -- (S1-2-1.south west) ;
\fill[red,alt=<4>{opacity=.2}{opacity=0}] (S1-2-1.south west) rectangle (S1-2-9.north east) ;

\begin{scope}[visible on=<4-6>]
    \node[anchor=west] at (0, -2) {d'où} ;
    \matrix[matrix of nodes,cells={nodes={minimum size=width("$-2$"), minimum height=1.5em,outer sep=0pt}}, %<-outer sep fixes overlap
ampersand replacement=\&, row 3/.style={visible on=<5->}, 
    below=of S1.south east,xshift={width("$2L_2$")-width("$L_2$")}, anchor=north east, align=left, yshift=1cm,
column sep=0pt] (S2) {
        $\phantom{-}2$ \& $x$ \& $+$ \&   \& $y$ \& $-$ \& $5$ \& $=$ \& $0$ \& $L_1$\\ % Why matrix of math nodes are not effective ? I need to add $...$
        \alt<4>{\color{red}{$-2$}}{$-2$} \& $x$ \& $+$ \& $4$ \& $y$ \& $-$ \& $16$ \& $=$ \& $0$ \& $\color{red}2\color{black}L_2$\\
        $\hphantom{-}0$ \& $x$ \& $+$ \& $5$ \& $y$ \& $-$ \& $21$ \& $=$ \& $0$ \& \rlap{$L_1+2L_2$} \\
    } ;
    \draw[decorate, decoration={brace, mirror, amplitude=5pt}] (S2-1-1.north west) -- (S2-2-1.south west) ;
    \draw<5-9> (S2-3-1.north west) -- (S2-3-9.north east) ;
\end{scope}
    \begin{scope}[alt=<5>{opacity=0.2}{opacity=0}]
        \fill[green]   (S2-1-1.west|-S2.north) rectangle (S2-3-2.east|-S2.south) ; % Why different nodes heights (ok for the lower part of y, though) ?
        \fill[cyan] (S2-1-3.west|-S2.north) rectangle (S2-3-5.east|-S2.south) ;    % I tried to set the height without success
        \fill[blue]  (S2-1-6.west|-S2.north) rectangle (S2-3-7.east|-S2.south) ;   % Why the colored blocks are overlapping by default ?
        \fill[orange] (S2-1-9.west|-S2.north) rectangle (S2-3-9.east|-S2.south) ;  % 
    \end{scope}
\fill<4>[red, opacity=.2] (S2-2-1.south west) rectangle (S2-2-9.north east) ;
\draw<4>[line width=4pt, red, -stealth] (S1-2-9.east) to [controls=+(-10:1) and +(0:1)] node[right] {$\pmb{\times 2}$} (S2-2-9.east) ; % How to use a transparency group to connect the two rectangular zone with a nice arrow ? I mean, how to blend it with various \uncover not happening all at the same moment ?

    \matrix[visible on=<7-10>,matrix of math nodes, nodes={minimum size=width("$-2$"), minimum height=1.5em}, ampersand replacement=\&, 
    below=of S1.south east, anchor=north east, align=left, xshift=5pt, yshift=1.3cm] (S3) {
        \hphantom{-0} \& \hphantom{x} \& \hphantom{+} \& $5$ \& $y$ \& $-$ \& $21$ \& $=$ \& $0$ \& \rlap{$L_1+2L_2$}\hphantom{$L_1$} \\
    } ;

    \matrix[matrix of math nodes, nodes={minimum size=width("$-2$"), minimum height=1.5em}, ampersand replacement=\&, 
    below=of S3.south east, anchor=north east, align=left, 
xshift=8pt, yshift=1.5cm,
visible on=<7-11>] (S4) {
        |[visible on=<11>]| $x$ \& |[visible on=<11>]| $=$ \& |[visible on=<11>]| $\dfrac25$ \& \hphantom{5} \& |[visible on=<10>]| et \& \hphantom{-} \& $y$ \& $=$ \& $\dfrac{21}{5}$ \& \hphantom{$L_1$} \\
    } ;

    \node[anchor=west,visible on=<10>] at (0,-2.8) (S5) {
        $2x+\dfrac{21}5-5=0$ d'où $2x+\dfrac{21}5-\dfrac{25}5=0$ d'où $2x=\dfrac45$ d'où $x=\dfrac25$.
    } ;

    \node[visible on=<12>] at (5.5,-2) {% How to position this text properly and relatively to other elements ?
        Ce système a pour solution $x=\dfrac25$ et $y=\dfrac{21}5$.
    } ;
\end{tikzpicture}


\pause

\begin{enumerate}
    \small
    \item On remarque qu'éliminer $x$ se fera simplement en multipliant $L_2$ par \tikzmarknode[minimum height=1em, inner sep=1pt, fill=green!20, fill on=<2-3>]{R3}{$2$}
    et en additionnant $L_1$ et $L_2$ : \pause
    le coefficient de $x$ dans $L_2$, qui vaut initialement \tikzmarknode[minimum height=1em, inner sep=1pt, fill=green!20, fill on=<3>, text=red, text on=<3>]{R4}{$-1$}, \pause
    passera alors à \tikzmarknode[minimum height=1em, inner sep=1pt, fill=red!20, fill on=<4>, text=red, text on=<4>]{R5}{$-2$}, \pause
    ce qui par sommation avec $L_1$ permettra d'éliminer l'inconnue $x$.\pause
    \item On obtient alors une équation à une inconnue facile à résoudre : $5y-21=0$ \pause d'où $5y=21$ d'où $y=\dfrac{21}5$.\pause
    \item On remplace alors $y$ par sa valeur dans $L_1$ ou $L_2$, au choix. \pause Comme $y$ figure seul dans $L_1$, sans coefficient, on choisit $L_1$.

\end{enumerate}
\end{frame}        
\end{document}

在此处输入图片描述

相关内容