8

I would like to have a rectangle split in two and have the text width of one side be fixed instead of having the textwidth apply to both sides.

I have the following.

\tikzstyle{pblock} = [rectangle split, rectangle split horizontal,
                      rectangle split parts=2, very thick,draw=black!50, top
                      color=white,bottom color=black!20, align=center]

Any help would be greatly appreciated.

16

You can pass the text width option directly to the \nodepart or you can set the

every <name> node part

style:

Sample output

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}
\tikzset{pblock/.style = {rectangle split, rectangle split horizontal,
                      rectangle split parts=2, very thick,draw=black!50, top
                      color=white,bottom color=black!20, align=center}}

\begin{tikzpicture}
  \node[pblock]{\nodepart[text width=1cm]{one} Some first text
                \nodepart{two}Some other text};
\end{tikzpicture}

\tikzset{/tikz/pblock/.append style = {every one node part/.style={text width=1cm}}}
\begin{tikzpicture}
  \node[pblock]{\nodepart{one} Some first text
                \nodepart{two}Some other text};
\end{tikzpicture}
\end{document}

Note you need to explicitly label the first part of the node for this to take effect.

See Should \tikzset or \tikzstyle be used to define TikZ styles? for discussion of \tikzset vs. \tikzstyle

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.