
Aquí está mi MWE:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[blue!20!black,fill=blue!20,rounded corners=10,thick] (0,0) rectangle (3,1) node {text};
\end{tikzpicture}
\end{document}
Me gustaría tener la palabra "texto" centrada dentro del nodo. Probé todo tipo de opciones y no funcionó.
Además, me gustaría dibujar un nodo idéntico a la derecha de este y tener una flecha entre los dos.
Respuesta1
En lugar de dibujar las formas y luego colocar un nodo en el centro, puede darle al nodo la forma que desee y luego colocar el nodo donde desee. Como desea que se repita el mismo nodo, puede definir un style
uso tikzset
que se pueda usar en múltiples tikzpictures.
\tikzset{mynode/.style={draw=blue!20!black, fill=blue!20, rounded corners=10, thick, minimum width=3cm, minimum height=1cm}}
Luego puedes colocar los nodos manualmente si lo deseas especificando sus coordenadas.
Pero aquí hay otras dos posibilidades de colocación.
Usando positioning
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw=blue!20!black, fill=blue!20, rounded corners=10, thick, minimum width=3cm, minimum height=1cm}}
\begin{document}
\begin{tikzpicture}[node distance=10mm]
\node[mynode](A){Text 1};
\node[mynode, right=of A](B){Text 2};
\node[mynode, right=of B](C){Text 3};
\draw[thick, ->](A)--(B);
\draw[thick, ->](B)--(C);
\end{tikzpicture}
\end{document}
Usando chains
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\tikzset{mynode/.style={draw=blue!20!black, fill=blue!20, rounded corners=10, thick, minimum width=3cm, minimum height=1cm}}
\begin{document}
\begin{tikzpicture}[start chain, node distance=10mm, every join/.style={->, thick}]
\node[on chain, mynode](A){Text 1};
\node[on chain=going right, mynode, join](B){Text 2};
\node[on chain=going right, mynode, join](C){Text 3};
\end{tikzpicture}
\end{document}
Colocación manual (espaciado ligeramente diferente porque esto coloca los centros de los nodos y no tiene en cuenta el grosor de los bordes de los nodos):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\tikzset{mynode/.style={draw=blue!20!black, fill=blue!20, rounded corners=10, thick, minimum width=3cm, minimum height=1cm}}
\begin{document}
\begin{tikzpicture}
\node[mynode] at (0,0) (A){Text 1};
\node[mynode] at (4,0) (B){Text 2};
\node[mynode] at (8,0) (C){Text 3};
\draw[thick, ->](A)--(B);
\draw[thick, ->](B)--(C);
\end{tikzpicture}
\end{document}