我怎样才能增加 tikz 内部积分的大小和箭头的长度

我怎样才能增加 tikz 内部积分的大小和箭头的长度

代码:

\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}

输出:

在此处输入图片描述

  1. 如何使 tikz 图片中的积分符号变得更大?
  2. 我如何才能使显示变换的箭头自动调整其长度以适应其上方表达式的大小?目前它短得多,导致文本重叠。

答案1

这是一个解决方案(使用\displaystyle制作更大的积分符号并使用node distance=2cm放大箭头)。

\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}

编辑:这是一个带有“自动调整”箭头的解决方案(使用\widthofcalc 包)。

\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}

相关内容