Math & ScienceArrow and equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
mayalaroz
Posts: 6
Joined: Wed Mar 27, 2013 3:13 pm

Arrow and equation

Post by mayalaroz »

Hello everibody,

I'm writing a rapport with a lot equations and I would like to use arrow to move from an equation from an another one. This is the code:

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}

\begin{document}
\begin{eqnarray*}
 \cos\theta dF &=& k_{\text{abs}}\rho_{a}dz \\
 &\begin{tikzpicture}
 \draw[<-] (0,0) -- (0,5);
 \end{tikzpicture}  &  \begin{tikzpicture}
 \draw[step=1cm, white] (0,0) grid(5,5);
 \node at (0,3.5) {$\tau\equiv\int_{z} k_{\text{abs}}\rho_{a}dz$ (la profondeur optique)};
 \node at (-2,2.5) {$\Leftrightarrow d\tau = -k_{\text{abs}}\rho_{a}dz$};
 \end{tikzpicture} \\
\end{eqnarray*}
\end{document}
But I have a problem: when I move from an equation to an another one, I have wrote an equation like comment but the form of my integral is too small in my opinion. So I have tried to enlarge this integral mais I don't see any change :oops: .
Moreover, the code I have written is a bit complicated and I wonder there is an easier code to write this system. Do you have an idea?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Arrow and equation

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

Here's a macro \tikzmark which you can use to position nodes anywhere, such as within math formulas. Later you can refer to those nodes for drawing.

Complete example:

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\newcommand{\tikzmark}[2][]{\tikz[overlay,remember picture,baseline=(#2.base)]
  \node (#2) {#1};}
\begin{document}
\begin{align*}
  \tikzmark{one}\cos\theta dF         &= k_{\text{abs}}\rho_{a}dz \\
                                 \tau &\equiv\int_{z} k_{\text{abs}}\rho_{a}dz
                                         \text{ (la profondeur optique)} \\
  \tikzmark{two}\Leftrightarrow d\tau &= -k_{\text{abs}}\rho_{a}dz
\end{align*}
\begin{tikzpicture}[overlay,remember picture]
  \draw[->,dashed,bend right=60] (one.south) to (two.north);
\end{tikzpicture}
\end{document}
Stefan
LaTeX.org admin
mayalaroz
Posts: 6
Joined: Wed Mar 27, 2013 3:13 pm

Arrow and equation

Post by mayalaroz »

Excuse me I have forgotten a line of my code :oops:

Code: Select all

  \documentclass[10pt,a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{tikz}

    \begin{document}
    \begin{eqnarray*}
     \cos\theta dF &=& k_{\text{abs}}\rho_{a}dz \\
     &\begin{tikzpicture}
     \draw[<-] (0,0) -- (0,5);
     \end{tikzpicture}  &  \begin{tikzpicture}
     \draw[step=1cm, white] (0,0) grid(5,5);
     \node at (0,3.5) {$\tau\equiv\int_{z} k_{\text{abs}}\rho_{a}dz$ (la profondeur optique)};
     \node at (-2,2.5) {$\Leftrightarrow d\tau = -k_{\text{abs}}\rho_{a}dz$};
     \end{tikzpicture} \\
     \cos\theta dF &=& Fd\tau
    \end{eqnarray*}
    \end{document}

In fact I would like to write an equation next the centre of the arrow (to comment my step of my calculation) but when my calculation is centered, the integrale of my calculation is too small. When I write this code:

Code: Select all

  \documentclass[10pt,a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{tikz}

\begin{document}
    \begin{eqnarray*}
     \cos\theta dF &=& k_{\text{abs}}\rho_{a}dz \\
     &\begin{tikzpicture}
     \draw[<-] (0,0) -- (0,5);
     \end{tikzpicture}  & \tau\equiv\int_{z} k_{\text{abs}}\rho_{a}dz \: \text{(la profondeur optique)} \\
      \cos\theta dF &=& Fd\tau
     \end{eqnarray*}
\end{document}
The integral has a normal size but it is not centered like the previous code. Do you know a solution? For example, a code like "\renewcommand" to modify the size of the arrow? Thank you for your welcome ;)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Arrow and equation

Post by Stefan Kottwitz »

Better use align* instead of eqnarray, as I did above. Compare the spacing around the relation symbols / equal signs in your diagram, eqnarray makes it wider.

For getting the math expressions in nodes in the same size, you can use \displaystyle:

Code: Select all

     \node at (0,3.5) {$\displaystyle\tau\equiv\int_{z}
       k_{\text{abs}}\rho_{a}dz$ (la profondeur optique)};
Stefan
LaTeX.org admin
mayalaroz
Posts: 6
Joined: Wed Mar 27, 2013 3:13 pm

Re: Arrow and equation

Post by mayalaroz »

Thank you very much Stefan ;).
Post Reply