Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Code:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{arrows,chains,positioning,scopes}
%
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
%
\tikzset{>=stealth',every on chain/.append style={join},
         every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
   execute at end node=$]
%
\begin{document}
\begin{tikzpicture}[start chain] {
    \node[on chain] {$\int \cos^3(2x) dx$};
    \node[on chain, join={node[above]
          {$dx \leftarrow \frac{1}{2} d2x$}}] {$\int \cos^3(2x) \frac{1}{2} d2x$} ;
  }
\end{tikzpicture}
$$
\int \cos^3(2x) dx
$$
\end{document}

Output:

enter image description here

  1. How can I make the integral symbol bigger in tikz picture?
  2. How can I make the arrow, that shows the transformation to auto-adjust it's length to the size of the expression above it? Currently it's much shorter, making the text overlap.
share|improve this question

1 Answer 1

up vote 4 down vote accepted

Here is a solution (using \displaystyle to make a bigger integral symbol and using node distance=2cm to enlarge the arrow).

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{arrows,chains,positioning,scopes}
%
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
%
\tikzset{>=stealth',every on chain/.append style={join},
         every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
   execute at end node=$]
%
\begin{document}
\begin{tikzpicture}[start chain,node distance=2cm] {
    \node[on chain] {$\displaystyle\int \cos^3(2x) dx$};
    \node[on chain, join={node[above]
          {$dx \leftarrow \frac{1}{2} d2x$}}] {$\displaystyle\int \cos^3(2x) \frac{1}{2} d2x$} ;
  }
\end{tikzpicture}
\[
\int \cos^3(2x) dx
\]
\end{document}

EDIT: here is a solution with "auto adjustable" arrow (using \widthof from calc package).

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{calc}
\usepackage{amsmath}
\usetikzlibrary{arrows,chains,positioning,scopes}
%
\makeatletter
\tikzset{
  join/.style={
    after node path={%
      \ifx%
      \tikzchainprevious\pgfutil@empty%
      \else
      (\tikzchainprevious)%
      edge[every join]#1(\tikzchaincurrent)
      \fi
    },
  },
}
\makeatother
%
\newlength{\mylen}
\tikzset{
  >=stealth',
  every on chain/.append style={join},
  every join/.style={->},
  join with arrow/.code={
    \setlength{\mylen}{\widthof{#1}}
    \tikzset{node distance=\mylen,on chain,join={node[above]{#1}}}
  },
}
%
\begin{document}
\begin{tikzpicture}[start chain] {
    \node[on chain] {$\displaystyle\int \cos^3(2x) dx$};
    \node[join with arrow={$dx \leftarrow \frac{1}{2} d2x$}]
    {$\displaystyle\int \cos^3(2x) \frac{1}{2} d2x$} ;
    \node[join with arrow={???}]
    {$\displaystyle\int \cos^3(2x) \frac{1}{2} d2x$} ;
  }
\end{tikzpicture}

\[
\int \cos^3(2x) dx
\]
\end{document}
share|improve this answer
    
Is it possible to make the arrow auto adjustable? Because I will have a chain of such transformations and the text at the top will always have different width. –  user4035 Aug 11 at 8:11
    
@user4035 I edited my answer... –  Paul Gaborit Aug 11 at 8:33
    
@user4035 Since I edited my answer, you may remove all your comments about the last line missing in the second example... ;-) –  Paul Gaborit Aug 14 at 14:24
    
" you may remove all your comments about the last line" - Done –  user4035 Aug 15 at 6:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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