Can't get new line at tikz diagram text
Use align=center
, or another option such as left
or right
.
\documentclass[tikz,margin=0.5cm]{standalone}
\begin{document}
\begin{tikzpicture}
\path (0,1) node[draw,rectangle,rounded corners,fill=green!80]{$P$} (0,-1) node[draw,rectangle,rounded corners,fill=green!80]{$Q$} (2,0) node[draw,rectangle,rounded corners,fill=green!80,align=center]{black \\ box};
\end{tikzpicture}
\end{document}
mostly off-topic (since you already got a solution), however some of suggestions can be useful to you:
- most of you preamble is not related to your problem, please nesxt time try to reduce it to minimum, i.e. provide minimal working example (mwe)
- for similar nodes is sensible to define style, for example
rbox/.style = {rectangle, draw, rounded corners, fill=#1, align=center},
which has free parameter for determining fill color - you can define default nodes color
give name to nodes (for simple drawings the lines between them)
\documentclass[a4paper,english,hebrew]{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[ rbox/.style = {rectangle, draw, rounded corners, fill=#1, align=center}, rbox/.default = green!80, ] \path (0, 1) node (p) [rbox]{$P$} (0,-1) node (q) [rbox]{$Q$} (2, 0) node (bb) [rbox=red!20]{black\\ box}; \draw[->] (p) -| (bb); \draw[->] (q) -| (bb); \end{tikzpicture} \end{document}