Forgot password
 Register account
View 64|Reply 17

请教在tikz中怎么把一个指向node.north的箭头向右移动一小段?

[Copy link]

412

Threads

1637

Posts

14

Reputation

Show all posts

abababa posted 2025-6-18 10:43 |Read mode
代码如下:
  1. \documentclass{article}
  2. \usepackage{tikz}
  3. \usepackage{amsmath,yhmath,amssymb}
  4. \usetikzlibrary{arrows,automata,positioning,matrix,calc,intersections,fit,shapes.geometric,3d}
  5. \usepackage[slantfont,boldfont]{xeCJK}
  6. \begin{document}
  7. \begin{center}
  8. \begin{tikzpicture}[node distance=1cm, auto]
  9. \tikzset {
  10.         node_box/.style={rectangle,rounded corners,draw=black, top color=white, bottom color=yellow!50,very thick, inner sep=1em, minimum size=3em, text centered},
  11.         arrow_box/.style={->, >=latex', shorten >=1pt, thick},
  12.         label_box/.style={text width=7em, text centered}
  13. }
  14. \node[node_box] (c-1) {c1};
  15. \node[below=of c-1] (dummy) {};
  16. \node[node_box, below=of dummy] (c-2) {c2};
  17. \node[left=of c-2] (dummy) {};
  18. \node[node_box, left=of dummy] (c-3) {c3};
  19. \node[right=of c-2] (dummy) {};
  20. \node[node_box, right=of dummy] (c-4) {c4};
  21. \node[right=of c-4] (dummy) {};
  22. \node[right=of dummy] (dummy) {};
  23. \node[right=of dummy] (dummy) {};
  24. \node[above=of dummy] (ddummy) {};
  25. \node[node_box, above=of ddummy] (c-5) {c5};
  26. \node[below=of dummy] (ddummy) {};
  27. \node[node_box, below=of ddummy] (c-6) {c6};
  28. \draw[arrow_box] (c-1.west) -| (c-3.north) node[pos=0.75, right]{xx};
  29. \draw[arrow_box] (c-1.east) -| (c-4.north) node[pos=0.75, left]{yy};
  30. \draw[arrow_box] (c-3.east) -- (c-2.west) node[pos=0.5, above]{zz};
  31. \draw[arrow_box] (c-4.west) -- (c-2.east) node[pos=0.5, above]{xx};
  32. \draw[arrow_box] (c-5.west) -| (c-4.north) node[pos=0.5, above]{yy};
  33. \end{tikzpicture}
  34. \end{center}
  35. \end{document}
Copy the Code
画图里最后一行的箭头和其它箭头重合了,请教怎么才能把那个箭头向右移动一小段?我查到的都是复杂的方法,要弄一个中间节点之类的东西,有没有简单点的方法?

679

Threads

110K

Posts

207

Reputation

Show all posts

kuing posted 2025-6-17 22:43
Last edited by kuing 2025-6-18 03:05非常简单:将最后一个 (c-4.north) 改成 (c-4.60) 即可。

PS、CSS 没了 word-wrap: break-word; ,第 4 行过长显示不完。
更新:某人不留痕迹偷偷地修改了第 4 行加个空格就当解决问题?可笑。还导致 1# 发表时间晚于 2# 回答时间,没见过这么乱搞的,呵呵。

412

Threads

1637

Posts

14

Reputation

Show all posts

original poster abababa posted 2025-6-18 10:24
kuing 发表于 2025-6-17 22:43
非常简单:将最后一个 (c-4.north) 改成 (c-4.60) 即可。

PS、CSS 没了  ,第 4 行过长显示不完。
原来如此,应该是指一个角度。还有一个问题,我想从c-3连到c-4,连法像这种:|___|,箭头指向c-4,然后在横向下方添加注释zz。我现在的做法是:
  1. \draw[arrow_box]
  2.         (c-3.south) -- ++(0,-1) coordinate (temp)
  3.         (temp) -- node[below]{zz} (c-4.south |- temp)
  4.         (c-4.south |- temp) -- (c-4.south);
Copy the Code

请教这个有没有什么简单方法,不用中间那些节点,就那么画过去。

3157

Threads

7925

Posts

48

Reputation

Show all posts

hbghlyj posted 2025-6-18 10:36
kuing wrote at 2025-6-17 22:43
还导致 1# 发表时间晚于 2# 回答时间,没见过这么乱搞的,呵呵。
是这样的:在编辑窗口右下角有一个“合并编辑时间”选项,用于微小改动,类似Wikipedia的minor edit。等效于删除后重新发一贴。

679

Threads

110K

Posts

207

Reputation

Show all posts

kuing posted 2025-6-18 16:11
hbghlyj 发表于 2025-6-18 10:36
是这样的:在编辑窗口右下角有一个“合并编辑时间”选项,用于微小改动,类似Wikipedia的minor edit。等效 ...
反对。
编辑他人帖子必须留下痕迹,用户有权知道自己的帖子被编辑过(包括编辑时间和编辑者)。
更合理地,在技术过关的前提下,还应该像绝大多数平台那样,能看到编辑日志——修改了什么地方。

412

Threads

1637

Posts

14

Reputation

Show all posts

original poster abababa posted 2025-6-18 17:09
abababa 发表于 2025-6-18 10:24
原来如此,应该是指一个角度。还有一个问题,我想从c-3连到c-4,连法像这种:|___|,箭头指向c-4,然后在 ...
现在换了下面的方法,简单了一点:
  1. \draw[arrow_box](c-3.south) -- ++(0,-1) -| (c-4.south) node[label_box, pos=0.25, below]{zz};
Copy the Code

Comment

pos=0.25 😅 明白了,0.5 是转折点,0.25 就是横线的中间……  posted 2025-6-18 17:28

412

Threads

1637

Posts

14

Reputation

Show all posts

original poster abababa posted 2025-6-18 17:10
kuing 发表于 2025-6-18 16:11
反对。
编辑他人帖子必须留下痕迹,用户有权知道自己的帖子被编辑过(包括编辑时间和编辑者)。
更合理地 ...
要不版主用现在的数据库重新开一个论坛吧,觉得现在这个已经被弄坏了

3157

Threads

7925

Posts

48

Reputation

Show all posts

hbghlyj posted 2025-6-18 17:12
只加了一个空格(小编辑)又去掉了空格

Comment

无关大小编辑的问题,这是原则问题,修改过就应该告知。  posted 2025-6-18 17:31
{:lengh:}  posted 2025-6-18 23:09

679

Threads

110K

Posts

207

Reputation

Show all posts

kuing posted 2025-6-18 17:54
abababa 发表于 2025-6-18 17:10
要不版主用现在的数据库重新开一个论坛吧,觉得现在这个已经被弄坏了。
我也想过再开“第4版”,甚至是重头开始,弄个全新的,不再延续这里的 discuz,但很明显我自己搞不定,到时恐怕问题更多,唉😔主要是不想再依靠别人,只恨自己技术不过关

Comment

淘宝出钱请人搞或者去贴吧  posted 2025-6-18 23:05
去贴吧开个涩kuing吧  posted 2025-6-18 23:06
专门发点不明显的涩图  posted 2025-6-18 23:07

412

Threads

1637

Posts

14

Reputation

Show all posts

original poster abababa posted 2025-6-18 18:12
kuing 发表于 2025-6-18 17:54
我也想过再开“第4版”,甚至是重头开始,弄个全新的,不再延续这里的 discuz,但很明显我自己搞不定,到 ...
我觉得我们这个是关于数学的论坛,所以不需要其它方面的东西,就是原本的什么都不改都很好,包括什么tikz代码能不能显示之类的,都是辅助功能(当初是觉得图片太大,占空间,放在别的网站又怕失效),这些都可以没有。

3157

Threads

7925

Posts

48

Reputation

Show all posts

hbghlyj posted 2025-6-18 19:25
显示“我编辑于…”则会使人以为我也是帖子内容贡献者之一
但是我的小编辑对于内容没有贡献,只是调整了格式,内容是归属于帖子作者的
应将这种编辑放在管理记录里,以便区分内容贡献者和格式调整者

679

Threads

110K

Posts

207

Reputation

Show all posts

kuing posted 2025-6-18 21:46
Last edited by kuing 2025-6-18 22:14
abababa 发表于 2025-6-18 17:09
现在换了下面的方法,简单了一点:
我从 tikz 手册学会了自定义 to path 的方法,实现了任意两点之间的 |__| 连线,两种方向,演示如下:
  1. \usetikzlibrary{calc}
  2. \tikzset{
  3. rto/.style={to path={--($(\tikztostart)!#1!-90:(\tikztotarget)$)--($(\tikztotarget)!#1!90:(\tikztostart)$)\tikztonodes--(\tikztotarget)}},
  4. lto/.style={to path={--($(\tikztostart)!#1!90:(\tikztotarget)$)--($(\tikztotarget)!#1!-90:(\tikztostart)$)\tikztonodes--(\tikztotarget)}}
  5. }
  6. \tikz[>=latex]{
  7. \node[draw] (a) at (0,0) {a};
  8. \node[draw] (b) at (2,1) {b};
  9. \draw[->] (a) to node[above]{to} (b);
  10. \draw[->] (a) to[rto=20pt] node[below]{rto} (b);
  11. \draw[->] (a) to[lto=20pt] node[above]{lto} (b);
  12. }
Copy the Code

这里的参数(=20pt)是必要参数,它是 (a) 与折点的距离,带单位就是绝对距离,如果不带单位,则单位是 (a) 到 (b) 的距离。
(注:这里 (a) 是一个 node 所以实际上是 (a) 的中心到折点的距离,而不是连线的始点到折点的距离)

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-6-21 10:04 GMT+8

Powered by Discuz!

Processed in 0.018177 seconds, 44 queries