我已经开始浏览 StackExchange 上所有我想用作示例的书签答案。大多数答案都可以在 Overleaf 中编译,我成功了。但是,我尝试从如何得到等式的倾斜等号?并将其答案导入 Overleaf。具体来说,我尝试使用:
\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}
当我在 Overleaf 中编译时,收到以下两个错误:
! 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.
我认为第二个错误(未找到名为 ex 的形状)是由于第一个错误没有创建节点造成的。
答案1
我认为缺少一个测试
\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}
答案2
添加这两个文件放入您的 overleaf 项目中,它就会工作。我遇到了同样的问题,但解决了。