Tikz。如何在节点之间绘制弧线?

Tikz。如何在节点之间绘制弧线?

如何绘制圆弧。如何以简单的方式添加蓝色圆弧? 在此处输入图片描述

或者以 3 个节点组成一条简单的线。

我对最后几行有疑问

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[x11names,table]{xcolor}
\usepackage{mathpazo}

\usepackage{tikz}
\usetikzlibrary{calc}% to calculate auxilary coordinates
\newcommand\tikznode[3][]{%
  \tikz[remember picture,baseline=(#2.base)]
    \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}

\tikzstyle{arrow}=[thick,->,>=stealth]
\tikzstyle{arrowr}=[red,thick,->,>=stealth]
\tikzstyle{arrowg}=[Green4,thick,->,>=stealth]
%
\usetikzlibrary{shapes,snakes}



\begin{document}
\begin{center}
  \begin{tabular}{ccc}
    \tikznode{diasupp}{} & \tikznode{cochupp}{} & \tikznode{mecupp}{} \\
    \tikznode{diasup}{} & \tikznode{cochup}{} & \tikznode{mecup}{} \\
    \tikznode{dias}{\underline{Días}} & \tikznode{coch}{\underline{Coches}} & \tikznode{mec}{\underline{Mecanicos}} \\
    %\midrule
    2 & 5 & 4 \\
    8 & 30 & $x$
  \end{tabular}
\end{center}

\begin{tikzpicture}[remember picture,overlay,red,thick]
  \draw [arrowr] (dias) -- (diasupp)--(mecupp)node[midway,sloped,left,rotate=0]{\raisebox{-.0\height}[46pt][50pt]I}--+(mec);
  \draw [arrowg] (coch) -- (cochup)--(mecup)node[midway,sloped,left,rotate=0]{\raisebox{-.0\height}[48pt][52pt]D}--+(mec);
  
  % The next lines is where the trouble is.
  %\path[->] (dias)  edge  [bend left=-20]  node[above] {$1$} (coch);
  %\path[->] (coch)  edge  [bend left=-20]  node[above] {$2$} (mec);
  %\path[->] (dias)  edge  [bend left=-36]  node[above] {$3$} (mec);
\end{tikzpicture}

\end{document}

答案1

你可能喜欢:

在此处输入图片描述

上面的图片是基于您的代码的。使用 tikzmarkbabe库生成。后者解决您的问题。

\documentclass[12pt, spanish]{article}
\usepackage{babel}
\usepackage[x11names,table]{xcolor}
\usepackage{mathpazo}

\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                quotes,
                tikzmark, 
                babel}
\tikzset{
  arr/.style = {draw=#1, very thick, -Stealth},
arr/.default = blue,
every edge/.style = {arr, bend right=30},
every edge quotes/.style = {font=\small, anchor=center, fill=white, inner sep=1pt}
        }

\begin{document}
    \begin{center}
    \setlength\tabcolsep{12pt}
    \renewcommand\arraystretch{1.5}
\begin{tabular}{@{} ccc @{}}
\tikzmarknode{A}{\underline{Días}} 
    &   \tikzmarknode{B}{\underline{Coches}} 
         &   \tikzmarknode{C}{\underline{Mecanicos}} \\
2   &  5 &  4     \\
8   & 30 & $x$    \\
\end{tabular}

\begin{tikzpicture}[remember picture,overlay]
\draw[arr=red]
        (A) -- ++(0,1.2) -| node[pos=.25, above] {I} (C.60);
\draw[arr=green]
        (B) -- ++(0,0.6) -| node[pos=.25, above] {D} (C.120);
\draw   (A) edge["1"]   (B)
        (B) edge["2"]   (C)
        (A) edge[bend right=45,
                 "3"]   (C);
\end{tikzpicture}
    \end{center}
\end{document}

但是,在问题中,您展示了所需结果的图像,其中蓝色箭头连接表格最后一行中的数字。它可以通过以下方式生成:

\documentclass[12pt, spanish]{article}
\usepackage{babel}
\usepackage[x11names,table]{xcolor}
\usepackage{mathpazo}

\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                quotes,
                tikzmark, 
                babel}
\tikzset{
  arr/.style = {draw=#1, very thick, -Stealth},
arr/.default = blue,
every edge/.style = {arr, bend right=30},
every edge quotes/.style = {font=\small, anchor=center, fill=white, inner sep=1pt}
        }

\begin{document}
    \begin{center}
    \setlength\tabcolsep{12pt}
\begin{tabular}{@{} ccc @{}}
\tikzmarknode{A}{\underline{Días}} 
    &   \tikzmarknode{B}{\underline{Coches}} 
        &   \tikzmarknode{C}{\underline{Mecanicos}} \\
2   & 5 &  4     \\
\tikzmarknode{D}{8}   
    & \tikzmarknode{E}{30} 
        & \tikzmarknode{F}{$x$}    \\
\end{tabular}

\begin{tikzpicture}[remember picture,overlay]
\draw[arr=red]
        (A) -- ++(0,1.2) -| node[pos=.25, above] {I} (C.60);
\draw[arr=green]
        (B) -- ++(0,0.6) -| node[pos=.25, above] {D} (C.120);
\draw   (D) edge["1"]   (E)
        (E) edge["2"]   (F)
        (D) edge[bend right=45,
                 "3"]   (F);
\end{tikzpicture}
    \end{center}
\end{document}

其生产成果为:

在此处输入图片描述

答案2

  1. 加载tikzbabel将解决使用问题\path[->] ...;
  2. \tikznode实际上是在重新实现包中的实用程序tikzmark. 在一般情况下,这个包非常有用。
  3. 对于您来说,该tikz \matrix命令特别有用。
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[x11names,table]{xcolor}
\usepackage{mathpazo}

\usepackage{tikz}
\usetikzlibrary{babel, matrix, arrows.meta}

\tikzstyle{arrow}=[thick,->,>=stealth]
\tikzstyle{arrowr}=[red,thick,->,>=stealth]
\tikzstyle{arrowg}=[Green4,thick,->,>=stealth]

\begin{document}

\begin{tikzpicture}
  \matrix (table) [matrix of nodes] {
    \underline{Días} & \underline{Coches} & \underline{Mecanicos} \\
    2 & 5 & 4 \\
    8 & 30 & $x$ \\
  };
  
  \draw[arrowr]
    (table-1-1.north) -- ++(0,1) -| node[pos=.25, above] {I} (table-1-3);
  \draw[arrowg]
    (table-1-2.north) -- ++(0,.3) -| node[pos=.25, above] {D} (table-1-3);
  \draw[blue,>={Triangle[scale=.8]}]
    (table-3-1) edge[bend right, ->] (table-3-2)
                edge[bend right=45, ->] (table-3-3)
    (table-3-2) edge[bend right, ->] (table-3-3);
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

西班牙语产生错误参见这里

我修好了。现在它应该可以画出你的箭头了。

\documentclass[12pt,spanish]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[x11names,table]{xcolor}
\usepackage{mathpazo}

\usepackage{tikz}
\usetikzlibrary{babel}
\usetikzlibrary{calc}% to calculate auxilary coordinates
\newcommand\tikznode[3][]{%
  \tikz[remember picture,baseline=(#2.base)]
    \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}

\tikzstyle{arrow}=[thick,->,>=stealth]
\tikzstyle{arrowr}=[red,thick,->,>=stealth]
\tikzstyle{arrowg}=[Green4,thick,->,>=stealth]
%
\usetikzlibrary{shapes,snakes}



\begin{document}
\begin{center}
  \begin{tabular}{ccc}
    \tikznode{diasupp}{} & \tikznode{cochupp}{} & \tikznode{mecupp}{} \\
    \tikznode{diasup}{} & \tikznode{cochup}{} & \tikznode{mecup}{} \\
    \tikznode{dias}{\underline{Días}} & \tikznode{coch}{\underline{Coches}} & \tikznode{mec}{\underline{Mecanicos}} \\
    %\midrule
    2 & 5 & 4 \\
    8 & 30 & $x$
  \end{tabular}
\end{center}

\begin{tikzpicture}[remember picture,overlay,red,thick]
  \draw [arrowr] (dias) -- (diasupp)--(mecupp)node[midway,sloped,left,rotate=0]{\raisebox{-.0\height}[46pt][50pt]I}--+(mec);
  \draw [arrowg] (coch) -- (cochup)--(mecup)node[midway,sloped,left,rotate=0]{\raisebox{-.0\height}[48pt][52pt]D}--+(mec);
  
  % The next lines is where the trouble is.
  \path[->] (dias)  edge  [bend left=-20]  node[above] {$1$} (coch);
  \path[->] (coch)  edge  [bend left=-20]  node[above] {$2$} (mec);
  \path[->] (dias)  edge  [bend left=-36]  node[above] {$3$} (mec);
\end{tikzpicture}

\end{document}

相关内容