1

enter image description here

I would like to position arrows next to text/through text like this, is there any possible way to do this?

2

There are plenty of possibilities, here is one of them.

\documentclass{article}
\usepackage{amsmath,xcolor}
\usepackage{tikz}
\newcommand{\tikznode}[2]{\relax
\ifmmode%
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$%\tikznodestyle 
  #2$};
\else
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}
\begin{document}
 $\tikznode{Al}{\textcolor{cyan}{\text{Al}}}^{\tikznode{3p}{\scriptstyle
 \textcolor{cyan}{3+}}}
 \quad\tikznode{O}{\textcolor{red}{\text{O}}}^{\tikznode{2m}{\textcolor{red}{\scriptstyle
2-}}}_{\tikznode{dummy}{\phantom{x}}}
 \longrightarrow
 \text{\textcolor{cyan}{Al}}_{\textcolor{red}{2}}\textcolor{red}{\text{O}}_{\textcolor{cyan}{3}}$
 \tikz[overlay,remember picture]{
 \draw[-latex] (3p)--(dummy.center);
 \draw[-latex] (2m)--(Al.south east);
 }
\end{document}

enter image description here

  • Very nice. Just a question, if I add like a blank suffix next to the O so that the arrow extends out a little more, what part of the text would I edit to select the reference characters? – Wertea Jun 18 '18 at 17:12
  • @Wertea I made an update. If you want to shorten the arrow from 2- to Al, just draw this arrow with \draw[-latex,shorten >=2pt] (2m)--(Al.south east);, say. – marmot Jun 18 '18 at 17:18
1

Does this look like what you like

equation with arrow crossing

Here is the code

\usepackage{tikz}
\usetikzlibrary{arrows.meta} %% Includes arrow head styles.

\begin{figure}[h]
\centering
\begin{tikzpicture}
\draw (-2,0) node[blue,left=0.02cm] {$\mathrm{Al^{3 +}}$}; %% write the Al ion
\draw (0,0) node[red,left=0.02cm] {$\mathrm{O^{2 -}}$}; %% write the O ion
\draw (3,0) node[left=0.02cm] {$\mathrm{{\color{blue}Al}_{{\color{red}2}} {\color{red}O}_{\color{blue}3}}$}; %% write the product
\draw [-{Stealth[round,scale=1.5]}] (-0.5 , 0.06) -- (-2.4 , -0.17); %% Arrow from O ion to Al ion.
\draw [-{Stealth[round,scale=1.5]}] (-2.15 , 0.06) --(-0.5 , -0.13); %% arrow from Al ion to O ion
\draw [-{Stealth[round,scale=1.5]}] (0 , 0) -- (1.7 , 0);
\end{tikzpicture}
\end{figure}

The order of \draw in the code is the actual order of drawing, which means the latter ones would be on top of the previous.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.