I have been having difficulties to make nodes fit the text in tikz.
What I have done so far:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, chains, fit, quotes,positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 7mm,
start chain = A going right,
txt/.style = {text height=2pt, text depth=2.pt,
on chain},
every edge/.append style = {draw, -stealth'}
]
\node [txt] {\phantom{ this is text }};
\node (f1) [ fill=blue!20,inner ysep=2.pt,
inner xsep=2pt,
anchor=text,
rectangle,
rounded corners=1mm,
fit=(A-1) (A-1)] {{ This is text}};
\end{tikzpicture}
\end{document}
Whereas the desired output should look like:
, which not only centers the text but also fits the node to the text (i.e. not using a lot of unneeded space).
Any thoughts


fit=(A-1) (A-1)in example, and it enlarges the node(f1). Can you explain where does node(A-1)come from? – muzimuzhi Z May 31 '20 at 20:09