Say I have a node:
\node [rectangle,label=above:$\text{rect…}$] (r0) at (0,0) {};
How can I horizontally center the text rect… above my rectangle?
Thanks in advance for your answers.
Kindly,
NS
Edit (MWE):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[x=01.00mm,y=00.50mm,node distance=10.00mm and 10.00mm,> = stealth',bend angle = 45,style = {font=\normalsize},every node/.style = {transform shape}]
\tikzset{tickh/.style={rectangle,text width=0,text height=0,fill=black,align=center,minimum width=4,minimum height=20,outer sep=0,inner sep=0,scale=0.5}}
\tikzset{rct/.style={trapezium angle=90,minimum width=20,fill=gray!100!black}}
\node [tickh,label={below:$\textit{aa}_i$}] (x1) at (0,0) {};
\node [rct,label={above:$\textit{bb}_j$},xshift=-03.50mm] (t0) [above=+02.00 of x1.center,anchor=south east] {};
\end{tikzpicture}
\end{document}
EDIT #2:
It appears that the line style = {font=\normalsize}
is causing the problem. It is probably a conflict with some package I'm using because it doesn't cause any problem on minimal examples. I'll post an answer if I find which one it is.
Best Answer
i guess, that you looking for the following:
labels positioned by
above
orbelow
are always horizontal centered regarding to a node's anchor north or south respectively (if you not shift them withxshift
).your mwe has errors and contains some illogicality. i correct them and add explanations as comments in code: