5

From my MWE below, I wanted to get this effect: enter image description here

How can I have the text show up in different lines as shown above?

Here is my code:

\documentclass{book}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{mathptmx}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}
\usepackage{accents}
\newcommand\myubar[1]{%
\underaccent{\bar}{#1}}

\begin{document}

\begin{equation*}
\tikz[baseline]{\node(d4) {$\hat{\myubar{\theta}}_{k+1}$}} = \tikz[baseline]{\node(d5){$\hat{\myubar{\theta}}_{k}$}} + \tikz[baseline]{\node(d6) {$K_{k+1}$}}\tikz[baseline]{\node(d7){$(\underbrace{y_{k+1}-h'_{k+1}\hat{\myubar{\theta}}_{k}})$}}
\end{equation*}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue,thick,->] (d4) to [in=90,out=245] + (225:2.7cm) node[anchor=north,text = black,] {$current~estimate$};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(235:1.8cm) node[anchor=north,text = black,] {$previous~estimate$};
\draw[blue,thick,->] (d6) to [in=90,out=265] +(235:1.4cm) node[anchor=north,text = black,] {$(gain)\newline The~weight\\of~the~adjustment$};
\draw[blue,thick,->] (d7) to [in=90,out=265] +(235:1.4cm) node[anchor=north,text = black,] {$(gain)\newline The~weight\\of~the~adjustment$};


\end{tikzpicture}

\end{document}
  • 1
    You might want to use cartesian coordinates instead of radial (225:27cm) if you want more than one node on a line.. Basically, what you have looks good except that the last three nodes overlap. Partly they are too close together, partly because the line breaks aren't doing anything. You should specify a\ parbox or us text width=. Also, what is with the $...$? Do you want \textit{...}? – John Kormylo Nov 1 '15 at 17:31
7

illustrated equation

\documentclass{book}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{mathptmx}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}
\usepackage{accents}
\newcommand\myubar[1]{%
\underaccent{\bar}{#1}}

\begin{document}

\begin{equation*}
\tikz[baseline]{\node(d4) {$\hat{\myubar{\theta}}_{k+1}$}} = \tikz[baseline]{\node(d5){$\hat{\myubar{\theta}}_{k}$}} + \tikz[baseline]{\node(d6) {$K_{k+1}$}}\tikz[baseline]{\node(d7){$(\underbrace{y_{k+1}-h'_{k+1}\hat{\myubar{\theta}}_{k}})$}}
\end{equation*}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue,thick,->] (d4) to [in=90,out=245] + (225:2.7cm) node[anchor=north,text = black] {current estimate};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(235:1.8cm) node[anchor=north,text = black] {previous estimate};
\draw[blue,thick,->] (d6) to [in=90,out=265] +(270:2.3cm) node[anchor=north,text = black,text width=3cm,align=center]
 {(gain)\\ The weight\\ of the adjustment};
\draw[blue,thick,->] (d7) to [in=90,out=265] +(290:1.4cm) node[anchor=north,text = black,text width=3cm,align=center]
 {(gain)\\ The~weight\\ of the adjustment};
\end{tikzpicture}

\end{document}

Here is an alternative using one tikzpicture to add the nodes (no overlay) and another to draw the lines (overlay).

aligned nodes

\documentclass{book}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{mathptmx}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}
\usepackage{accents}
\newcommand\myubar[1]{%
\underaccent{\bar}{#1}}

\begin{document}

\begin{equation*}
\tikz[baseline]{\node(d4) {$\hat{\myubar{\theta}}_{k+1}$}} = \tikz[baseline]{\node(d5){$\hat{\myubar{\theta}}_{k}$}} + \tikz[baseline]{\node(d6) {$K_{k+1}$}}\tikz[baseline]{\node(d7){$(\underbrace{y_{k+1}-h'_{k+1}\hat{\myubar{\theta}}_{k}})$}}
\end{equation*}
\vspace{1cm}\par
% insert text
\noindent\hfil\begin{tikzpicture}
\node (t1) {current estimate};
\node[above right] (t2) at (t1.east) {previous estimate};
\node[right,text width=2.5cm,align=center] (t3) at (t2.east)
 {(gain)\\ The weight\\ of the adjustment};
\node[right,text width=2.5cm,align=center] (t4) at (t3.east)
 {(gain)\\ The~weight\\ of the adjustment};
\end{tikzpicture}
% insert lines between text
\begin{tikzpicture}[overlay]
\draw[blue,thick,->] (d4) to [in=90,out=245] (t1.north);
\draw[blue,thick,->] (d5) to [in=90,out=265] (t2.north);
\draw[blue,thick,->] (d6) to [in=90,out=265] (t3.north);
\draw[blue,thick,->] (d7) to [in=90,out=265] (t4.north);
\end{tikzpicture}

Following text starts here.

\end{document}
  • Couldn't you simplify the code a little with the tikzmark library (I think that is what is is called) – daleif Nov 1 '15 at 18:14
  • @dalleif - It's actually better they way he set it up. I would have to insert \tikzmark into the center of certain math expressions, or figure out the offsets to the center. – John Kormylo Nov 1 '15 at 18:28
  • Doesn't it just wrap around it? Might be me that is mistaken – daleif Nov 1 '15 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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