如何处理包含低于基线的文本的文本节点?
我在使用 Tikz/Latex 时遇到以下问题:
我有一些包含文本的节点。大多数文本没有低于基线的字母。但对于发生这种情况的节点,节点高度和文本/基线的比例和位置是关闭的。看一下示例图像。
我所知道的解决方案:
- 将节点的最小高度调大。这会导致节点大小相同,但基线仍处于不同高度
- 使用 struts。这会导致所有节点的布局与包含违规文本的节点类似。这会导致大多数节点的文本基线与周围框之间的空间过大
I have the following problem with Tikz/Latex:
I have some nodes that contain text. Most text doesn't have letters that reach below the baseline. But for those nodes where it happens, the ratio and placement of node height and text/baseline is off. Have a look at the example image.
Solutions I know of:
- make the nodes' minimum height bigger. This results in the nodes being sized the same, but the baseline is still at different heights
- use struts. This results in all nodes being laid out like the ones containing the offending text. This results in too much space between the baseline of the text and the surrounding box for most nodes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
节点有一个属性:
文本深度
对于有问题的(或所有)节点,只需将其设置为
0pt
即可。注意
当然,
pgfmanual
中有详细记录。There's a property for nodes:
text depth
One can simply set it to
0pt
for the offending (or all) nodes.Note
Of course this is well documented in the
pgfmanual
.这更像是一个指针(目前无法获取 TikZ),但由于您没有获取其他任何内容,因此可以尝试两件事:
1)有
$\smash[b]{\text {my text y}}$
(为此您需要amsmath
)。2)也许
\raisebox{0pt}[0pt]{my text y}
就是你想要的。This is more of a pointer (can't get TikZ at the moment), but since you are not getting anything else, there are two things to try:
1) There is the
$\smash[b]{\text{my text y}}$
(you needamsmath
for this).2) Maybe
\raisebox{0pt}[0pt]{my text y}
is what you want.