5

So I have tkiz style:

\tikzset{
state/.style={
       rectangle,
       rounded corners,
       draw=black, very thick,
       minimum height=2em,
       inner sep=2pt,
       text centered,
       },

How I can split this rectangle to two parts, with different colors, like:

|----|
| red|
|----|
|blue|
|____|

And how I could write text in different lines, but in same part. Or I should another command?

Thanks in advance.

9

The rectangle split shape from the shapes.multipart library can do this.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\tikzset{
state/.style={
       rectangle split,
       rectangle split parts=2,
       rectangle split part fill={red!30,blue!20},
       rounded corners,
       draw=black, very thick,
       minimum height=2em,
       text width=3cm,
       inner sep=2pt,
       text centered,
       }
}
\begin{document}
\begin{tikzpicture}
\node [state] {text\\txet \nodepart{two} blue background \\ here};
\end{tikzpicture}
\end{document}
  • how to make bigger spaces between rectangles? :) – Mantas Mar 29 '16 at 14:11
  • @Mantas Does adding inner ysep=10pt, (or some other value) do what you want? – Torbjørn T. Mar 29 '16 at 14:15
  • No :) I have no spaces between rectangles now. Its more like width or something :) – Mantas Mar 29 '16 at 14:15
  • inner sep isn't doing the job :/ Still no spaces between rectangles... – Mantas Mar 29 '16 at 14:16
  • @Mantas I don't understand, do you want a gap between the red and the blue part? Your last comment I don't understand at all. – Torbjørn T. Mar 29 '16 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.