Forgot password?
 Create new account
View 1410|Reply 7

tikz这两种方式竟然不等价,关于line width

[Copy link]

700

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2018-6-10 18:17:11 |Read mode
\tikz{
\node[inner sep=0pt] (x) {X};
\draw[gray,opacity=0.5,line width=2pt] (x.south west) rectangle (x.north east);
}
\tikz[line width=2pt]{
\node[inner sep=0pt] (x) {X};
\draw[gray,opacity=0.5] (x.south west) rectangle (x.north east);
}
它们的效果分别是:
QQ截图20180610181613.png

@isee 你用最新版texlive试试看是不是也是这样?

700

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2018-6-10 18:27:16
而且,前者的线的中间也并不是在 x 的边界上,这可以通过将线宽改小看来出,比如:
\tikz{
\node[inner sep=0pt] (x) {X};
\draw[line width=.05pt] (x.south west) rectangle (x.north east);
}
\tikz[line width=.05pt]{
\node[inner sep=0pt] (x) {X};
\draw (x.south west) rectangle (x.north east);
}
效果:
QQ截图20180610182659.png

801

Threads

4888

Posts

310K

Credits

Credits
36170

Show all posts

isee Posted at 2018-6-10 23:33:35
回复 1# kuing


这当然效果不同。
首先,我本地执行效果与你一样。

其次,当然不同啦  

\tikz{
\node[inner sep=0pt,line width=2pt] (x) {X};
\draw[gray,opacity=0.5,line width=2pt] (x.south west) rectangle (x.north east);
}  

才和第二个代码等价,不信你试。

难得你出现这样的低级错误

700

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2018-6-10 23:41:50
回复 3# isee

哦,看来我对 node 的理解不到位。
是不是说,node 就算没画线,但也会有一个 line width 的宽度存在?

801

Threads

4888

Posts

310K

Credits

Credits
36170

Show all posts

isee Posted at 2018-6-10 23:48:52
回复 4# kuing


我更不懂,反正第二种是全局的。。。。。

700

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2018-6-11 00:28:18
回复 4# kuing

准确说应该是,node 的边框不管画不画,它的边角方位点(.north 等这些)都是包括那线宽的。
测试了下似乎是这样……

801

Threads

4888

Posts

310K

Credits

Credits
36170

Show all posts

isee Posted at 2018-6-11 00:42:11
回复 6# kuing


实际效果是这样,我以前也碰到多,但没多想

700

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2018-6-11 00:53:54
回复 7# isee

我以前都没注意到,而且改变线宽通常都在全局改,今天在测试一些符号时写在了局部,才发现了。

手机版Mobile version|Leisure Math Forum

2025-4-21 14:09 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list