I've got some coordinates in a tikz-picture and I'd like to draw some rectangles defined by two opposing corner coordinates. The seemingly easiest way to do that I found with this answer: Placing a rectangular node in tikz by specifying two opposing corners. However I can't manage to get the text vertically and horizontally centered within the drawn rectangle.
I fiddled around with various anchor points within my tikzset{...}
and the text centered
property, but they all seem to only affect the box, not the text.
MWE:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fit}
\tikzset{
block/.style 2 args = {
draw, line width = 1pt, inner sep=0pt, outer sep=0pt,
fit=(#1) (#2),}
}
\begin{document}
\begin{tikzpicture}[x=1mm,y=1mm]
\draw[step=1cm,gray,very thin] (-10,-10) grid (70,70);
\coordinate[](0_r1) at (0,22.5);
\coordinate[](0_r2) at (0,42);
\coordinate[](0_r3) at (0,49);
\coordinate[](b1_r2) at (14.4,42);
\coordinate[](b1_r3) at (14.4,49);
\coordinate[](b1_r4) at (14.4,59,0);
\node[block={0_r1}{b1_r2}] {$R_{mki1}$};
\node[block={0_r2}{b1_r3}] {$R_{mr1}$};
\node[block={0_r3}{b1_r4}] {$R_{mko1}$};
\end{tikzpicture}
\end{document}
I'm open for other ways for drawing the rectangles, but they need to be defined by predefined coordinates. Also I need to vary the line styles and filling of every rectangle, so I'd like to keep the tikzset
as simple as possible and define this properties outside.