2

I'd like to find a "simple" way to highlight two pieces of text and connect them with a path and a label on it.

For example, I need to make a slideshow to demonstrate how to solve linear systems to my pupils. I want to insist on some mathematical transformations I need to use by hilighting (with colors) and connecting parts on various formulas (with path and label nodes on it).

I have no MWE yet, as I'm still struggling with my first attempts, mixing TikZ and Beamer. I do know how to use \alt{colored maths}{standard maths}, I'm aware of the package aobs-tikz, but I cannot figure out how to use it with plain text and maths (it's difficult for me to handle the various size issues, like gaps with base line, etc.).

Is it possible to have a non-intrusive code that would say "create a node with this name, containing these maths, change its appearance from this to this steps" and then, at the end of the slide, create a tikzpicture with overlay settings that would allow me to connect this and this name on the right steps...

Hoping to be clear, thanks in advance for any help.

Edit : here is a not working very well example... Note that formulas are not well aligned on baseline, and that I cannot link them.

\documentclass{beamer}
\usepackage{etex}
\usepackage[utf8]{luainputenc} % --> oui ! Ça fonctionne pour œ !
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\hypersetup{pdfencoding=utf8}
\usepackage{pgfplots,tikz}
\usetikzlibrary{arrows, arrows.meta, bending, calc, fadings, hobby, positioning, shadows, shadows.blur, shapes, shapes.misc, tikzmark}
\usetikzlibrary{overlay-beamer-styles}

\begin{document}

\begin{frame}
    \textbf{\Large Exemple}

    \small Résoudre $\begin{cases}3x+2y-4=0 & L_1 \\ 2x-5y-7=0 & L_2\end{cases}$\pause
    \begin{enumerate}[<+->]
        \item On isole $y$ dans $L_1$ : \pause $2y=-3x+4$ \pause d'où $y=-\dfrac32x+2$\pause
        \item Dans $L_2$, on remplace $y$ par l'expression précédente : \pause $2x-   \tikz[baseline] { \node[fill=red!40, fill on=<9>] (A) {$\!5\left(-\dfrac32x+2\right)\!$} ; }-7=0$ \pause
            d'où $2x+\tikz[baseline] { \node[fill=red!40, fill on=<9>] (B) {$\dfrac{15}2x-10$} ;}-7=0$ \pause
            d'où $\dfrac42x+\dfrac{15}2x-17=0$
    \end{enumerate}
    \begin{tikzpicture}[overlay]
        \draw[<->, red!40, very thick, draw on=<9>] (A) edge [bend left] (B) ;
    \end{tikzpicture}
\end{frame}

\end{document}

enter image description here

1 Answer 1

2

Something like this? I use \tikzmarknodes, which simplify things since they e.g. detect that one is in math mode, and visible on=<.(1)>, a trick that I learned from samcarter, which allows one to avoid hardcoded numbers like 9.

\documentclass{beamer}
\usepackage{etex}
\usepackage[utf8]{luainputenc} % --> oui ! Ça fonctionne pour œ !
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\hypersetup{pdfencoding=utf8}
\usepackage{pgfplots,tikz}
\usetikzlibrary{arrows, arrows.meta, bending, calc, fadings, hobby, positioning, shadows, shadows.blur, shapes, shapes.misc, tikzmark}
\usetikzlibrary{overlay-beamer-styles}

\begin{document}

\begin{frame}
    \textbf{\Large Exemple}

    \small Résoudre $\begin{cases}3x+2y-4=0 & L_1 \\ 2x-5y-7=0 & L_2\end{cases}$\pause
    \begin{enumerate}[<+->]
        \item On isole $y$ dans $L_1$ : \pause $2y=-3x+4$ \pause d'où $y=-\dfrac32x+2$\pause
        \item Dans $L_2$, on remplace $y$ par l'expression précédente : \pause $2x-   \tikzmarknode[fill=red!20,inner sep=1.5pt, fill on=<.(2)>]{A}{5\left(-\dfrac32x+2\right)}-7=0$ \pause
            d'où $2x+\tikzmarknode[fill=red!20,inner sep=1.5pt, fill on=<.(1)>]{B}{\dfrac{15}2x-10}-7=0$\begin{tikzpicture}[overlay,remember picture]
        \draw[<->, red!40,stealth-stealth, very thick,visible on=<.(1)>] (A.north east) to[bend left] (B.north west) ;
    \end{tikzpicture}
 \pause
            d'où $\dfrac42x+\dfrac{15}2x-17=0$
    \end{enumerate}
    \end{frame}

\end{document}

enter image description here

6
  • Thanks again. I'm now one step closer to my goal, but I'd want all the highlights appear at the same time, and disappear simultaneously too. I succeeded in getting the background change at the same time by changing the first tkizmarknode to \tikzmarknode[fill=red!20, inner sep=1.5pt, fill on=<.(2)>]{A}, but I cannot get the arrow showing at the same time this way... Nice trick, by the way ! I also notice something odd that I cannot explain : "double pauses" after "On isole y dans L1" and "Dans L2, on remplace y par l'expression précédente :"...
    – natsirt
    Commented Oct 14, 2019 at 17:23
  • 1
    @natsirt Sorry, I missed that requirement. Better now?
    – user194703
    Commented Oct 14, 2019 at 18:13
  • 1
    Found the problem with the "double pause" : it is related to the option of the enumerate [<+->].. But why ? It's explained here : tex.stackexchange.com/questions/71165/…
    – natsirt
    Commented Oct 14, 2019 at 19:23
  • 2
    See also tex.stackexchange.com/q/682/86 about the double pauses. Commented Oct 14, 2019 at 19:28
  • 1
    @natsirt The overlay specification .(1) means "on the current slide only". As I said, I learned it from samcarter, i.e. I couldn't figure it out from reading the beamer manual. And as for the double pauses: your and @LoopSpace's links provide an explanation and a fix. (I actually did not read the question carefully enough to appreciate the issue, my bad.)
    – user194703
    Commented Oct 14, 2019 at 23:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .