6

This is a basic question and I apologize if this program is using the latest version of the tikzmark library not available in CTAN. I posted as far as I got and also the image I am trying to replicate. Please assist in finishing the program.

\documentclass{article}
\usepackage{amsmath,mathtools,geometry}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\newbox\aebox
\newcommand\aecomment[2][0pt]{%%
  \begin{lrbox}\aebox
    \begin{minipage}[t]{2.5in}
      \raggedright
      \textcolor{blue}{#2}%%
    \end{minipage}%%
  \end{lrbox}%%
  \raisebox{#1}[\height][0pt]{\usebox{\aebox}}}

\begin{document}
For $f(x)=\dfrac{1}{x}$, we have

\begin{align*}
        f(x+h)&=\dfrac{1}{x+h} \\
\shortintertext{then}\\
                    f(x+h)-f(x)&=\dfrac{1}{x+h}-\dfrac{1}{x} \\ \\
                           &=\dfrac{1}{x+h} \cdot \textcolor{red} 
   {\dfrac{\tikzmarknode{C}{x}}{x}}-\dfrac{1}{x}\cdot \textcolor{red} 
   {\dfrac{x+h}{x+h}} && \aecomment[1.3ex]{\textcolor{red}{\tikzmarknode{A} 
   {}Multiplying by $1$ to get a common denominator}}\\
   \end{align*}

\begin{tikzpicture}[overlay,remember picture]
\draw[red] ([yshift=3pt,xshift=-5pt]A.west) -- ++(-7pt,0pt)-- ++ (0pt,7pt);
\end{tikzpicture}


\end{document}

enter image description here

I am trying to recreate

enter image description here

I keep compiling errors each attempt to recreate the arrows.....

MathScholar
  • 2,513

1 Answers1

5

The newest tikzmarklibrary is now for a while in the standard TeX distributions, so everything is fine, and it is really easy to draw the arrows.

\documentclass{article}
\usepackage{amsmath,mathtools,geometry}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\newbox\aebox
\newcommand\aecomment[2][0pt]{%%
  \begin{lrbox}\aebox
    \begin{minipage}[t]{2.5in}
      \raggedright
      \textcolor{blue}{#2}%%
    \end{minipage}%%
  \end{lrbox}%%
  \raisebox{#1}[\height][0pt]{\usebox{\aebox}}}

\begin{document}
For $f(x)=\dfrac{1}{x}$, we have

\begin{align*}
        f(x+h)&=\dfrac{1}{x+h} \\
\shortintertext{then}\\
                    f(x+h)-f(x)&=\dfrac{1}{x+h}-\dfrac{1}{x} \\ \\
                           &=\dfrac{1}{x+h} \cdot \textcolor{red} 
   {\dfrac{\tikzmarknode{C}{x}}{x}}-\dfrac{1}{x}\cdot \textcolor{red} 
   {\dfrac{x\tikzmarknode{C'}{+}h}{x+h}} && \aecomment[1.3ex]{\textcolor{red}{\tikzmarknode{A} 
   {}Multiplying by $1$ to get a common denominator}}\\
   \end{align*}

\begin{tikzpicture}[overlay,remember picture]
\draw[red,-latex] ([yshift=3pt,xshift=-5pt]A.west) -- ++(-7pt,0pt)-- ++ (0pt,12pt)
coordinate (aux)-| (C.north);
\draw[red,-latex] (aux) -| (C'.north);
\end{tikzpicture}


\end{document}

enter image description here

  • yes I am getting the same error. I don't understand why? The error is that the shape C' is not known and I have the tikzmarknode label and copy from your program – MathScholar Nov 22 '18 at 00:27
  • @MathScholar I do not get any error (obviously, otherwise I wouldn't have posted this code). Did you update your TeX distribution? (I am using the official version of tikzmark that comes with the standard TeX distributions and is also available from CTAN.) –  Nov 22 '18 at 00:30
  • I guess I have to update and yes I see your output but why it work from the node A I posted. – MathScholar Nov 22 '18 at 00:30
  • I tried it on a different program from the past and it compiled so it is not an update issue. Very strange but this has happened before. – MathScholar Nov 22 '18 at 00:34
  • yes I ran it separately and got your output but when I run this as part of my larger program I get an error. I don't know what to say but the code is rejected in the larger program. – MathScholar Nov 22 '18 at 00:40
  • @MathScholar Sorry to hear that but I cannot do much except for providing complete codes that run through. (My crystal ball got stolen.) –  Nov 22 '18 at 00:42
  • I think there is an incompatibility issue with the packages I am using in the larger program? I did not design tikzmark but notice there are others who ran into this problem. Thank s for your help Marmot – MathScholar Nov 22 '18 at 01:08
  • I got rid of package flexisym and it went through. I don't know what this package is exactly. Last time it was pgfplots. Not pulling your leg. This is a head scratching . Try inserting \usepackage{flexisym} on your end and see if you have the same situation – MathScholar Nov 22 '18 at 01:26
  • Why is there a {} in \aecomment[1.3ex]{\textcolor{red}{\tikzmarknode{A}{}Multiplying by $1$ to get a common denominator}}\? – manooooh Nov 22 '18 at 02:25
  • @MathScholar If you post the full preamble (preferably in form of a new question since I will be offline now) I guess somebody will be able to help, –  Nov 22 '18 at 02:25
  • 1
    @manooooh I don't know, I really focussed on the arrows, thanks for checking, will look at it in a few hours... –  Nov 22 '18 at 02:26
  • @MArmot hi Marmot same Preamble as above except when I add the package flexisym the error occurs. I am curious it that happens for you? The package was apart of a larger template. I have your program running, so THANK YOU but just want to let you know what I ran into – MathScholar Nov 22 '18 at 02:38
  • 1
    @MathScholar Yes, it does. I really encourage you to post a minimal question with that content (I am about to start driving) and hope that Joseph Wright will see it. (I am already scared by the statement in the manual "For now, the user’s guide is in breqn.". breqn is known to modify catcodes. You could try if these tricks here help, but there is a chance that you get ultimately told not to use the package.) –  Nov 22 '18 at 02:44
  • I will do now. Drive safely! – MathScholar Nov 22 '18 at 02:51
  • 1
    @manooooh You have a good point, \tikzmarknode{A}{} just creates an empty node. In principle, this is not what \tikzmarknode is made for, I think. On the other hand. it is also not wrong, strictly speaking. –  Nov 22 '18 at 05:49