方程式内で矢印を強調表示して使用する

方程式内で矢印を強調表示して使用する

私は、私がしようとしていることを非常に単純な例えで説明しようとしていますLaTeX。私は単に、2つのベクトルを、一方を下または他方の隣に書き、ノードを使用して最初のベクトルの最後の2つの要素と2番目のベクトルの最後の要素をリンクしたいだけです。これが私が使用しているコードです。

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}% For nice arrow tips
% One style for all TikZ pictures for working with overlays:
\tikzset{every picture/.style=remember picture}
% Define a TikZ node for math content:
\newcommand{\mathnode}[1]{%
  \mathord{\tikz[baseline=(#1.base), inner sep = 0pt]{\node (#1) {$#1$};}}}



\begin{document}

$\begin{bmatrix}
     1 \\ \mathnode{2\rho \pi \\ 3}
\end{bmatrix}$
\\
$\begin{bmatrix}
     1 \\ 2\rho \pi \\ \mathnode{3}
\end{bmatrix}$

% Now we draw connections between defined nodes:
\begin{tikzpicture}[overlay]
  \path [>=stealth, <->, shorten <= 3pt, shorten >=3 pt]
    (N1) edge [bend left=60] (N2);
\end{tikzpicture}


\end{document}

ノードに名前を付け、各ノードを個別に入力できるように、mathnode 宣言を変更するにはどうすればよいですか?

何か提案はありますか?

ありがとう。

答え1

あなたが考えている出力はよくわかりませんが、私なら間違いなく、 nor をmatrix使用せずに、同じ tikzpicture に 2 つのノードのマトリックスを配置するtikz の方法を実行します。remember pictureoverlay

例えば:

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}% For nice arrow tips
\begin{document}

\tikzset{
    !/.style = {
        fill=yellow!30,
    },
    mymatrix/.style = {
        matrix of math nodes,
        left delimiter  = (,
        right delimiter = ),
        nodes={minimum width=6ex},
    }
}

\begin{tikzpicture}
    \matrix[mymatrix, name=M1]{
                1 \\
        |[!]|   2\rho\pi \\
        |[!]|   3\\
    };
    \matrix[mymatrix, name=M2, below=of M1] {
                 1 \\
                 2\rho\pi\\
        |[!]|    3\\
    };
   \draw [red, >=stealth, <->, shorten <= 3pt, shorten >=3 pt]
     (M1-2-1.south east) to[bend left=60] (M2-3-1.east);
\end{tikzpicture}

\end{document}

生産:

結果

答え2

によってhf-tikz、TikZ を利用する必要はありませんmatrix。これは、そのようなタスクを実行する方法を示した例です。

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath, amssymb}
\usepackage[customcolors,markings]{hf-tikz}
\usetikzlibrary{calc}

\tikzset{aspect/.style={
    set fill color=green!50!lime!60,
    set border color=white,
    disable rounded corners=true
  },
  vert offsets/.style={
    above offset=0.32,
    below offset=-0.08
  },
  expr/.style={
    left offset=-0.05,
    right offset=0.25,
    vert offsets,
    aspect,
  },
  number/.style={
    left offset=-0.1,
    right offset=0.1,
    vert offsets,
    aspect
  }
}

\begin{document}
\[\begin{bmatrix}
     1 \\ \tikzmarkin[expr, mark at=0.135]{a}2\rho \pi \\ 3\tikzmarkend{a}
\end{bmatrix}
\]
% store the point in a coordinate: let it be a bit shifted for clarity
\tikz[remember picture,overlay]\coordinate[use marker id,xshift=0.1cm] (A) at (0,0);

\[\begin{bmatrix}
     1 \\ 2\rho \pi \\ \tikzmarkin[number, mark at=0.135]{b}3\tikzmarkend{b}
\end{bmatrix}
\]
% store the point in a coordinate: let it be a bit shifted for clarity
\tikz[remember picture]\coordinate[use marker id,xshift=0.25cm] (B) at (0,0);

% draw the curve
\tikz[remember picture,overlay]\draw[blue] 
 (A) edge[bend left=60,stealth-stealth](B);
\end{document}

結果:

ここに画像の説明を入力してください

このmarkingsオプションは、パッケージのバージョン0.3の機能であり、Jakeが答えてくれた素晴らしい回答に基づいています。TikZ でパス上の任意の点の接線を描く方法. これは TikZmarkingsライブラリを利用しており、マーカーを 0 (パスの開始) から 1 (パスの終了) までの番号として配置することができます。マーカーが配置されている場所を表示するには、show markersキーを使用します。例:

\[\begin{bmatrix}
     1 \\ \tikzmarkin[expr, show markers, mark at=0.135]{a}2\rho \pi \\ 3\tikzmarkend{a}
\end{bmatrix}
\]

...

\[\begin{bmatrix}
     1 \\ 2\rho \pi \\ \tikzmarkin[number,show markers, mark at=0.135]{b}3\tikzmarkend{b}
\end{bmatrix}
\]

与える:

ここに画像の説明を入力してください

さらに、このパッケージでは、シェーディングの観点からアスペクト スタイルを定義することができます。これらは、数式を強調表示するたびに個別に適用できます。これらを使用する 1 つの方法は次のとおりです。

  • たとえば、スタイルの一般的な側面をいくつか定義しますaspect x
  • オフセット定義と引数を含むスタイルを定義します。これにより、適切なアスペクト スタイルが選択されます。例: expr=aspect x

これはいくつかの可能性を網羅した例です:

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath, amssymb}
\usepackage[customcolors,shade,markings]{hf-tikz}
\usetikzlibrary{calc}

\tikzset{aspect 1/.style={
    set border color=green!70!black,
    top color=white,
    bottom color=green!50!lime!60,
    disable rounded corners=true
  },
  aspect 2/.style={
    set border color=cyan!50!blue,
    bottom color=white,
    top color=cyan!50!blue!60,
    disable rounded corners=true
  },
  aspect 3/.style={
    set border color=white,
    inner color=white,
    outer color=red!75!black!30,
    disable rounded corners=true
  },  
  vert offsets/.style={
    above offset=0.32,
    below offset=-0.08
  },
  expr/.style={
    left offset=-0.05,
    right offset=0.25,
    vert offsets,
    #1,
  },
  number/.style={
    left offset=-0.1,
    right offset=0.1,
    vert offsets,
    #1
  }
}

\begin{document}
\[
\begin{bmatrix}
     1 \\ \tikzmarkin[expr=aspect 1, mark at=0.135]{a}2\rho \pi \\ 3\tikzmarkend{a}
\end{bmatrix}
% store the point in a coordinate: let it be a bit shifted
\tikz[remember picture,overlay]\coordinate[use marker id,xshift=0.1cm] (A) at (0,0);
\hspace{1cm}
\begin{bmatrix}
     1 \\ \tikzmarkin[expr=aspect 2, mark at=0.135]{a2}2\rho \pi \\ 3\tikzmarkend{a2}
\end{bmatrix}
% store the point in a coordinate: let it be a bit shifted
\tikz[remember picture,overlay]\coordinate[use marker id,xshift=0.1cm] (A2) at (0,0);
\hspace{1cm}
\begin{bmatrix}
     1 \\ \tikzmarkin[expr=aspect 3, mark at=0.135]{a3}2\rho \pi \\ 3\tikzmarkend{a3}
\end{bmatrix}
% store the point in a coordinate: let it be a bit shifted
\tikz[remember picture,overlay]\coordinate[use marker id,xshift=0.1cm] (A3) at (0,0);
\]


\[
\begin{bmatrix}
     1 \\ 2\rho \pi \\ \tikzmarkin[number=aspect 3, mark at=0.135]{b}3\tikzmarkend{b}
\end{bmatrix}
% store the point in a coordinate: let it be a bit shifted
\tikz[remember picture]\coordinate[use marker id,xshift=0.25cm] (B) at (0,0);
\hspace{1cm}
\begin{bmatrix}
     1 \\ 2\rho \pi \\ \tikzmarkin[number=aspect 1, mark at=0.135]{b2}3\tikzmarkend{b2}
\end{bmatrix}
% store the point in a coordinate: let it be a bit shifted
\tikz[remember picture]\coordinate[use marker id,xshift=0.25cm] (B2) at (0,0);
\hspace{1cm}
\begin{bmatrix}
     1 \\ 2\rho \pi \\ \tikzmarkin[number=aspect 2, mark at=0.135]{b3}3\tikzmarkend{b3}
\end{bmatrix}
% store the point in a coordinate: let it be a bit shifted
\tikz[remember picture]\coordinate[use marker id,xshift=0.25cm] (B3) at (0,0);
\]


% draw the curve
\tikz[remember picture,overlay]\draw[cyan!50!blue] 
 (A) edge[bend left=60,stealth-stealth](B);
\tikz[remember picture,overlay]\draw[red!75!black] 
 (A2) edge[bend left=60,stealth-stealth](B2);
\tikz[remember picture,overlay]\draw[green!70!black] 
 (A3) edge[bend left=60,stealth-stealth](B3);
\end{document}

結果:

ここに画像の説明を入力してください

関連情報