5

Following the instructions of some posts here on stackexchange, I have used the following codes to generate the attached image of an equation. However, I would also like to have the terms inside the square brackets highlighted in blue. In addition, I would like to annotate the first term on the right side of the equation i.e. (1-delta) with highlighting. It's my first time using the tikz package and I am struggling with this terribly. I have already checked out the example from http://www.texample.net/tikz/examples/beamer-arrows. But since I am very new, I could not make much of it.

I will be immensely grateful if someone could help me here with codes and their explanations.

\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Madrid}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{tikzmark, positioning, arrows,shapes}

\begin{document}

\begin{frame}{Household}
with the law of motion of capital,
\begin{equation}
\label{capmot}
K_{t+1}^p= (1-\delta)K_t^P + I_t^P\tikzmark{pdt}{\left[1 - \dfrac{\chi}{2}\left(\dfrac{I_t^P}{I_{t-1}^P} -1 \right)^2 \right]}
\end{equation}
\begin{tikzpicture}[
  remember picture,
  overlay,
  expl/.style={draw=orange,fill=orange!30,rounded corners,text width=3cm},
  arrow/.style={red!80!black,ultra thick,->,>=latex}
]
\node<2->[fill=blue!20,anchor=base,expl] 
  (pdtex) 
  at (6,3.5cm)
  {Investment Adjustment Cost};
\draw<2->[arrow]
  (pdtex.west) to[out=180,in=180] ([yshift=0.5ex]{pic cs:pdt});  
\end{tikzpicture}
\end{frame}
\end{document}

P.S. I require the annotations to appear one by one on click.

2 Answers 2

6

Here is a proposal. To change the color to blue, you can use \alert after telling beamer to use blue for \alert. I also change the way you add the box by using a callout and \tikznode for more precise highlighting.

\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Madrid}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{tikzmark, positioning, arrows,shapes}
\usetikzlibrary{shapes.callouts,shadows.blur,positioning}
\usetikzlibrary{overlay-beamer-styles}
\setbeamercolor{alerted text}{fg=blue}
\newcommand{\tikznode}[2]{\relax
\ifmmode%
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
\else
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}

\begin{document}

\begin{frame}{Household}
with the law of motion of capital,
\begin{equation}
\label{capmot}
K_{t+1}^p= \alert<2>{\tikznode{del}{(1-\delta)}}K_t^P + 
I_t^P\alert<3>{\tikznode{pdt}{\left[1 -
\dfrac{\chi}{2}\left(\dfrac{I_t^P}{I_{t-1}^P} -1 \right)^2 \right]}}
\end{equation}
\begin{tikzpicture}[
  remember picture,
  overlay,
  expl/.style={draw=orange,fill=orange!30,rounded corners,text width=3cm},
  arrow/.style={red!80!black,ultra thick,->,>=latex}
]
\node[alt={<2>{drop shadow,opacity=0.8,text opacity=1}{invisible}},
visible on=<2>, 
align=center, fill=blue!20, align=center, 
rounded corners,draw,rectangle callout,
anchor=pointer,callout relative pointer={(-300:1cm)}]
at (del) {Depreciation};
\node[alt={<3>{drop shadow,opacity=0.8,text opacity=1}{invisible}},
visible on=<3>, 
align=center, fill=blue!20, align=center, 
rounded corners,draw,rectangle callout,
anchor=pointer,callout relative pointer={(230:1cm)}]
at (pdt.north) {Investment Adjustment Cost};
\end{tikzpicture}
\end{frame}

\end{document}

enter image description here

6
  • Thank you for your input. I beg apology if my question and requirements were not clear enough. 1. I require the whole term inside the square bracket "[..]" to be highlighted, annotated and pointed toward. Your example points toward only I_t^p. 2. I required the term (1-delta) not only highlighted but also annotated and pointed toward by an arrow. I shared a link containing an example of the kind of highlighting I was referring too: texample.net/tikz/examples/beamer-arrows This example shows blocks of equations being colored (i.e. highlighted).
    – TRa
    Jul 10, 2018 at 17:52
  • @TRa Sorry for misreading. Both operations at the same time or in which order? And what's the difference between "highlighted, annotated and pointed toward" and "also annotated and pointed toward by an arrow"? That is, where should the arrow start?
    – user121799
    Jul 10, 2018 at 17:58
  • (1-delta) should appear first on click, then the term inside the third bracket. I did not intend to mean any difference between " highlighted, annotated and pointed toward" and "also annotated and pointed toward by an arrow". I need both terms highlighted, annotated, and pointed toward. The annotation for (1-delta) should read something like "Depreciation". Sorry for the confusion.
    – TRa
    Jul 10, 2018 at 18:03
  • 1
    @TRa OK, made an update, please have a look.
    – user121799
    Jul 10, 2018 at 18:10
  • thanks a bunch. Although this not exactly how I wanted the highlight to look like, it's sufficient for my purpose.
    – TRa
    Jul 10, 2018 at 18:13
2

To change the color of a part of an equation you can use the package xcolor:

\usepackage{xcolor}
...
$ x \textcolor{blue}{y} z $

Resulting in: partially colored equation

To change a part of a slide from one frame to the next you can use \only:

We are on slide \only<1>{one}\only<2>{two}

Will result in the text changing from 'one' to 'two'. Between the < > you put the slide number.

You can combine the two inside an equation for the effect you desire:

$ x \only<1>{y}\only<2>{\textcolor{blue}{y}} z $

The y will become blue once you go to slide 2.

3
  • Thanks for chiming in. I don't want to change the color of the text, I just want them to be highlighted as done here: texample.net/tikz/examples/beamer-arrows . Could you also please answer my 2nd question: "In addition, I would like to annotate the first term on the right side of the equation i.e. (1-delta) with highlighting."
    – TRa
    Jul 10, 2018 at 10:13
  • @TRa Ah, I now understand what you mean. I don't quite know how to get desired effect. I am however wondering what the difference is between your two questions. In the first question you seem to want highlighting and in the second question you want to annotate with highlighting. Can you elaborate on the different results you want?
    – Flexo013
    Jul 10, 2018 at 10:32
  • I apologize if my 2nd question was not clear. I managed to annotate one portion of the equation, but I failed to annotate another portion. The arrow does not point to the second portion, rather points to the first portion that I already annotated (codes not shown here).
    – TRa
    Jul 10, 2018 at 10:34

You must log in to answer this question.

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