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.....

1 Answer 1

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

15
  • 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 Commented Nov 22, 2018 at 0: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.)
    – user121799
    Commented Nov 22, 2018 at 0:30
  • 1
    @manooooh I don't know, I really focussed on the arrows, thanks for checking, will look at it in a few hours...
    – user121799
    Commented Nov 22, 2018 at 2:26
  • 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.)
    – user121799
    Commented Nov 22, 2018 at 2:44
  • 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.
    – user121799
    Commented Nov 22, 2018 at 5:49

You must log in to answer this question.

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