文章预览
选自: https://ask.latexstudio.net/ask/question/17311.html 【如题】 造了个轮子 \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \ begin {document} \makeatletter \ def \ pgfgetnodeheight ( #1)#2{ \path ($( #1.south) - (#1.north)$); \pgfmathsetmacro #2{veclen(\pgf @x , \pgf @y )} \edef #2{#2pt} } \ def \ pgfgetnodewidth ( #1)#2{ \path ($( #1.east) - (#1.west)$); \pgfmathsetmacro #2{veclen(\pgf @x , \pgf @y )} \edef #2{#2pt} } \makeatother \ begin {tikzpicture} \node[anchor = south west, draw, align = left] (a) {text width \\ text width}; \pgfgetnodewidth(a) \nWidth \pgfgetnodeheight(a)\nHeight \draw[red] ( 0 , -. 1 ) -- (\nWidth, -. 1 ) node[midway, below, text = black] {\nWidth};; \draw[blue] (-. 1 , 0 ) -- (-. 1 , \nHeight) node[midway, left, text = black] {\nHeight}; \ end {tikzpicture} \ end {document} 关注我们公众号,学习 LaTeX 无烦恼! 入门资料,免费知识代码: https://flowus.cn/latex/share/66110e84-b24a-4c
………………………………