2

I would like to place a text next to an arrow. The figure below shows how I would like it to look. I tried to use the commands ^ and _ and also \hspace and \vspace, but it is not getting the way you want. Maybe there is a command like \overbrace or \underbrace that helps me, but I don't know it.

enter image description here

My code:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\newcommand\myarrow{%
  \tikz\draw[red,dashed,thick,-Triangle] (0,0) -- ++(0,-1.1);
}
\begin{document}
\begin{frame}
$\begin{array}{cccccc}
 & f(x) & = & \sqrt{x^2 + 500^2} \cdot 640,00 & + &  (2000 - x) \cdot 312,00\\ 
  &  &  &  &  &  \\
   &  &  & \myarrow_{\color{red}(\sqrt{x})' = \frac{1}{2\sqrt{x}}} &  & \myarrow \\
 &  &  &  &  &  \\ 
\Rightarrow & f'(x) & = & 640,00\frac{1}{2\sqrt{x^2 + 500^2}}2x & + & 312,00(-1) 
\end{array} $
\end{frame}
\end{document}

The result is:

enter image description here

I need this derivative to be higher. Another way I tried was to put it to the side as text, but the \tiny and \small commands are not working.

PS: I have already asked some questions about how to do some commands for a presentation, I am trying to look for the answers, but I believe that they are not trivial things and are difficult to find on the net.

Croos
  • 225

2 Answers2

4

I propose this other solution, which doesn't require TiKZ – just an alignat* environment and the eqparbox` package.

\documentclass{beamer}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\begin{document}

\begin{frame} \begin{alignat}{2} f(x) & = \eqmathbox[L]{\sqrt{x^2 + 500^2} \cdot 640,00} & & + \eqmathbox[R]{(2000 - x) \cdot 312,00}\ &\phantom{ = } \eqmathbox[L]{\scriptstyle\color{red}\biggl\downarrow(\sqrt{u})' = \tfrac{u'}{2\sqrt{u}}} & & \phantom{ + } \eqmathbox[L]{\scriptstyle\color{red}\biggl\downarrow}\%& & \myarrow \ \Rightarrow f'(x) & = \eqmathbox[L]{640,00\frac{2x}{2\sqrt{x^2 + 500^2}}} & & + \eqmathbox[R]{312,00(-1)} \end{alignat} \end{frame}

\end{document}

enter image description here

Bernard
  • 271,350
2

It's better (in my opinion) to use a TikZ matrix, since you need TikZ. Then you can use matrix nodes and the result it's very simple. For the big size my solution is to put \displaymath inside the math and you have it.

I'll give you an example with a couple of changes (I personally like it better how it looks like this, but change it to your liking).

\documentclass {beamer}
\usepackage    {cancel}
\usepackage    {siunitx} % Better look for decimal numbers
\usepackage    {tikz}

\sisetup {group-minimum-digits=3,output-decimal-marker={,}} \usetikzlibrary{calc} \usetikzlibrary{arrows.meta} \usetikzlibrary{matrix}

\begin{document} \begin{frame} \begin{tikzpicture}[line cap=round,line join=round] % It's necessary for TikZ matrix and beamer to change the ampersands \matrix(D)[matrix of nodes,row sep=2cm,column sep=0cm,ampersand replacement=&] { & $f(x)$ & $=$ & $\underbrace{\num{640,00}\cdot\sqrt{x^2+500^2}}$ & $+$ & $\underbrace{\num{312,00}\cdot(\num{2000}-x)}$\ $\Rightarrow$ & $f'(x)$ & $=$ & $\displaystyle\overbrace{\num{640,00}\cdot\frac{\cancel{2}x}{\cancel{2}\sqrt{x^2+500}}}$ & $+$ & $\overbrace{\num{312,00}\cdot(-1)}$\ }; \draw[thick,red,dashed,-Triangle] (D-1-4) -- (D-2-4); \draw[thick,red,dashed,-Triangle] (D-1-6) -- (D-2-6); \node[red] at ($(D-1-4)!0.5!(D-2-4)$) [right] {$\displaystyle(\sqrt{x})'=\frac{1}{2\sqrt{x}}$}; \end{tikzpicture} \end{frame} \end{document}

It looks like this: enter image description here

EDIT: My first attempt was a standalone instead of a beamer. Putting the TikZ matrix inside a frame produces an error. There is a conflict with beamer an TikZ. The solution was to change the ampersand & for another thing, in my case \&. There is more information in: "Single ampersand used with wrong catcode" error using tikz matrix in beamer

Juan Castaño
  • 28,426
  • It was good, I didn't understand how to make the smaller size of the red part next to the arrow. – Croos Jan 09 '21 at 17:05
  • I'm giving a presentation in \documentclass{beamer}, and your code is giving an error. I liked what you did, do I need another package for the beamer case? – Croos Jan 09 '21 at 17:24
  • It works form me in beamer too. You need only the listed packages: cancel (if you want to cancel in the fraction) and siunitx (if you want my display of numbers, if you not remove the \nums). – Juan Castaño Jan 09 '21 at 17:35
  • For making bigger the derivative you need to put the `\displaystyle' command in the math environment. – Juan Castaño Jan 09 '21 at 17:36
  • The code that is giving an error is \sisetup {group-minimum-digits=3,output-decimal-marker={,}} – Croos Jan 09 '21 at 17:40
  • If remove this code the error is in \end{frame} – Croos Jan 09 '21 at 17:46
  • Did you put the siunitx package? If you did I don't know the problem. But you can remove the \sisetup{...}' and all the\num{...}` commands. I think that it'll work this way too – Juan Castaño Jan 09 '21 at 17:47
  • I used the package siunitx and if I remove the error is in \ end {frame} – Croos Jan 09 '21 at 18:12
  • I think I found the error. I'm editing in a moment. Take a look at this: https://tex.stackexchange.com/questions/15093/single-ampersand-used-with-wrong-catcode-error-using-tikz-matrix-in-beamer – Juan Castaño Jan 09 '21 at 18:23
  • It worked. Thank you for your help. – Croos Jan 09 '21 at 20:09