如何精确定位节点中的文本?

如何精确定位节点中的文本?

我想将文本A放入节点矩形的右下角,而不更改任何其他内容。请帮帮我。

\documentclass[10pt]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw [help lines] (0,0) grid (40pt,40pt);
\node [draw,minimum height = 30pt, minimum width = 30pt, inner sep = 0] at (15pt,15pt) {$A$};
\end{tikzpicture}
\end{document}

enter image description here

答案1

您可以使用label在节点内放置一些文本:

\documentclass[10pt]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw [help lines] (0,0) grid (40pt,40pt);
\node [draw,minimum height = 30pt, minimum width = 30pt, inner sep = 0, 
      label={[anchor=south east, draw=red, inner sep=0pt]south east:$A$}] 
      at (15pt,15pt) {$A$};
\end{tikzpicture}
\end{document}

enter image description here

相关内容