2

I have started going through all of the bookmarked answers on StackExchange that I want to use for examples. I have had success with most of the answers being able to compile within Overleaf. However, I tried importing the code from How do I get a tilted equal sign for an equation? and its answer into Overleaf. Specifically I tried to use:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[\lim_{x\to0}\tikzmarknode{ex}{\mathrm{e}^x}\left(2+4x\right)~=~2\]
\begin{tikzpicture}[overlay,remember picture]
\path[red] ([xshift=1pt,yshift=1pt]ex.north east) -- ++(45:{width("=")*1pt-1pt})
node[midway,sloped]{$=$} node[above right=-2pt]{$1$};
\end{tikzpicture}
\end{document}

When I compile in Overleaf I receive the following two errors:

! Undefined control sequence.
l.6 \[\lim_{x\to0}\tikzmarknode{ex}{\mathrm{e}^x}\left(2+4x\right)~=~2\]
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.


! Package pgf Error: No shape named ex is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
...                                              

l.8 ...red] ([xshift=1pt,yshift=1pt]ex.north east)
                                              -- ++(45:{width("=")*1pt-...
This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.

I believe that the second error (No shaped named ex is found) is due to the first error not creating the node.

MrT_PHS
  • 33
  • Unfortunately I am having issues getting MikTeX to work on my school laptop to test out the same code using current libraries. – MrT_PHS Jun 21 '19 at 18:27
  • The version of tikzmark in Overleaf doesn't have \tikzmarknode. I even used this macro as a test to find out the version of tikzmark here. You can copy the code of tikzmark from CTAN and upload it to your project. – Phelype Oleinik Jun 21 '19 at 18:34

2 Answers2

1

I think there is a test missing

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[\lim_{x\to0}\tikzmarknode{ex}{\mathrm{e}^x}\left(2+4x\right)~=~2\]
\iftikzmark{ex}{\begin{tikzpicture}[overlay,remember picture]
\path[red] ([xshift=1pt,yshift=1pt]ex.north east) -- ++(45:{width("=")*1pt-1pt})
node[midway,sloped]{$=$} node[above right=-2pt]{$1$};
\end{tikzpicture}}{}
\end{document}
Ulrike Fischer
  • 327,261
0

Add these two files into your overleaf project, and it will work. I had the same problem and that worked it out.

  • Thanks Pedro. After getting it to work on my local install I added those files to Overleaf and was successful. I am trying to make templates and examples for my students to use when typing up their homework answers, I guess that I will have to put those files in our class Google Drive so that they can include them when using this technique. – MrT_PHS Jun 26 '19 at 14:57