Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there an easy way to stretch a node in a matrix environment in TikZ over several columns? In the following example I want to merge the three nodes in the second row as one wide node.

Any idea?

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
[auto,
mytext/.style={thick, text width=4.5em,inner sep=1pt},
line/.style ={draw, thick, -latex',shorten >=2pt},
block/.style ={rectangle,text width=6em,draw,minimum height=4em, outer sep=0pt}]
\matrix [column sep=1cm,row sep=7mm]
{
 % 1. row
 \node [mytext] (st0) {Step 1}; &
 \node [block] (cl0) [label=above:\textbf{Climate}] {rainfall and temperature}; &
  \node [block] (veg0) [label=above:\textbf{Vegetation}] {forest}; &
  \node [block] (sol0) [label=above:\textbf{Soil and terrain}]
  {soil}; \\
 % 2. row
 \node  (st2) {some text}; &
 \node [block] (cl1) {this blocks}; &
 \node [block] (veg1) {should be}; &
 \node [block] (sol1) {merged together}; \\

\\ };
\tikzstyle{every path}=[line]
\path (cl0) -- (cl1);
\path (veg0) -- (veg1);
\path (sol0) -- (sol1);

\end{tikzpicture}

\end{document} 

enter image description here

share|improve this question

1 Answer 1

it is certainly not the cleanest method, but probably the simplest

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows,fit}

\begin{document}

\begin{tikzpicture}
[auto,
mytext/.style={thick, text width=4.5em,inner sep=1pt},
line/.style ={draw, thick, -latex',shorten >=2pt},
block/.style ={rectangle,text width=6em,draw,minimum height=4em, outer sep=0pt},
blocka/.style ={rectangle,text width=6em,minimum height=4em, outer sep=0pt}]
\matrix [column sep=1cm,row sep=7mm]
{
 % 1. row
 \node [mytext] (st0) {Step 1}; &
 \node [block] (cl0) [label=above:\textbf{Climate}] {rainfall and temperature}; &
  \node [block] (veg0) [label=above:\textbf{Vegetation}] {forest}; &
  \node [block] (sol0) [label=above:\textbf{Soil and terrain}]
  {soil}; \\
 % 2. row
 \node  (st2) {some text}; &
 \node [blocka] (cl1) {}; &
 \node [blocka] (veg1) {}; &
 \node [blocka] (sol1) {}; \\

\\ };
\tikzstyle{every path}=[line]
\path (cl0) -- (cl1);
\path (veg0) -- (veg1);
\path (sol0) -- (sol1);

\node[block] (outer) [fit=(cl1) (veg1) (sol1)] {this blocks should be merged together};

\end{tikzpicture}

\end{document} 

enter image description here

otherwise: Multirow/multicolumn cells in TikZ matrices?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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