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.

I want to draw something like this:

enter image description here

I am able to draw like this:

enter image description here

This is the code for the same:

\documentclass{article}
\usepackage{tikz,subfig}
\begin{document}

\begin{figure}
  \centering
  \subfloat[Iteration Domain for a Tile]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
  \subfloat[Convex Bounding Boxes]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
  \subfloat[Disjoint Bounding Boxes]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
  \subfloat[Disjoint Bounding Boxes]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
  \caption{Bounding boxes for disjoint union of data regions}
\end{figure}

\end{document}

Now, I am facing two problems:

  1. How can place center aligned text exactly above figure 1(b) and both figure 1(C) and (d)?
  2. How do I draw a rectangle above figure (b), (c) and (d) only?

Is there any way to do it?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

You need something like this,

\begin{figure}
  \centering
  \begin{tabular}[t]{cccc}
    &\multicolumn{3}{c}{
      \begin{tikzpicture}
        \draw (0,0) rectangle (10.0,0.8);
      \end{tikzpicture}
    }\\
  &{\bfseries Something}&\multicolumn{2}{c}{\bfseries Something}\\
  \subfloat[Iteration Domain for a Tile]{
....
  }&
  \subfloat[Convex Bounding Boxes]{
....
  }&
  \subfloat[Disjoint Bounding Boxes]{
....    
}&
  \subfloat[Disjoint Bounding Boxes]{
....    
}
\end{tabular}
  \caption{Bounding boxes for disjoint union of data regions}
\end{figure}

My result was this,

enter image description here

To control the inter-column spacing, use \setlength{\tabcolsep}{some value} and other inter-row space control techniques to control vertical placements.

share|improve this answer

For the question 1, use a tabular with 3 centered columns:

  \begin{tabular}{ccc} foo & foo & foo\\ 
  \subfloat[Iteration Domain for a Tile]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
 & 
  \subfloat[Convex Bounding Boxes]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
 & 
  \subfloat[Disjoint Bounding Boxes]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
  \subfloat[Disjoint Bounding Boxes]{
      \begin{tikzpicture}
        \draw (0,0) rectangle (3.8,3.8);
      \end{tikzpicture}
  }
\end{tabular}
share|improve this answer

Another idea: put all your subfigures inside the same tikzpicture, and so you can use tikz commands to put labels relative to the boxes. You can use also tikz nodes to contain the subcaptions.

The problem here are the labels (a), (b), etc.. of each subcaption. There are two approaches:

  1. Manual. Write yourself (a), (b), etc as part of the text of the subcaption. This of course is suboptimal because you won't be able to \ref to these subcaptions, but if you don't need to do that it could be a simple solution.
  2. Use \subfloat as the content of the tikz node, so that the subcaptions are automatically numbered and labelled.

In the following code I followed the 2nd approach. The technique I used can be useful to other similar problems.

\documentclass{article}
\usepackage{tikz,subfig}
\usetikzlibrary{positioning,calc}
\begin{document}

\def\subcaption#1#2{
  \node[subcaption=#1]{\subfloat[#2]{\hskip\linewidth}};
}

\begin{figure}
  \centering
      \begin{tikzpicture}
        \tikzset{
          box/.style = {draw, rectangle, minimum width=3.8cm, minimum height=3.8cm, node distance=2mm},
          subcaption/.style = {below=-\baselineskip of #1, text width=4.2cm, inner sep=0pt},
          something/.style = {above=2mm of #1, font=\sffamily\bfseries\footnotesize},
          red bar/.style = {fill=red, draw=black, ultra thick, minimum width=10cm, minimum height=4mm},
        }
        \node[box] (a) {};
        \node[box,right=of a] (b) {};
        \node[box,right=of b] (c) {};
        \node[box,right=of c] (d) {};

        \subcaption{a}{Iteration Domain for a Tile};
        \subcaption{b}{Convex Bounding Boxes};
        \subcaption{c}{Disjoint Bounding Boxes};
        \subcaption{d}{Disjoint Bounding Boxes};

        \node[something=b] {Something};
        \coordinate (aux) at ($(c.north)!.5!(d.north)$);
        \node[something=aux] {Something};
        \node[red bar, above=1cm of c] {};
      \end{tikzpicture}
  \caption{Bounding boxes for disjoint union of data regions}
\end{figure}
\end{document}

Result:

Result

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.