Color – Adding a Border to Textblock

color

I'm pretty new to latex, and what I am trying to create a simple treemap, by simple I mean really simple.

I have managed to produce a simple box at a given position and width, but I'm not too sure how to create a border around the textblock.

\begin{textblock}{200}(400,200)
  \centering
  \textblockcolour{red}
  \vspace{20mm}
    { \bfseries \Large Hello World }
  \vspace{20mm}
\end{textblock}

My Example usage is below:

\documentclass{article}

\usepackage[a4paper]{geometry}
\usepackage[absolute,overlay]{textpos}
  \setlength{\TPHorizModule}{1mm}
  \setlength{\TPVertModule}{1mm}
  \setlength{\parindent}{0mm}
\usepackage{color}


\begin{document}

  \begin{textblock}{200}(400,200)
    \centering
    \textblockcolour{red}
    \vspace{20mm}
      { \bfseries \Large Hello World }
    \vspace{20mm}
  \end{textblock}

\end{document}

Any help would be appreciated.

Best Answer

You can use the showboxes package option (in the example below I changed the settings for the textblock since the original settings place the block outside the page):

\documentclass{article}
\usepackage[absolute,overlay,showboxes]{textpos}
\usepackage{xcolor}

\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\setlength{\parindent}{0mm}

\begin{document}

\begin{textblock}{200}(0,200)
  \centering
  \textblockcolour{red}
  \vspace{20mm}
    { \bfseries \Large Hello World }
  \vspace{20mm}
\end{textblock}

\end{document}

enter image description here

However, to draw your treemap I would suggest you to use PGF/TikZ instead.

Here's a simple possibility, using TikZ, to draw a treemap:

\documentclass{article}
\usepackage{tikz}

\definecolor{green1}{RGB}{221,242,151}
\definecolor{green2}{RGB}{161,221,135}
\definecolor{purple1}{RGB}{149,87,164}
\definecolor{blue1}{RGB}{42,144,158}

\begin{document}

\begin{tikzpicture}

\draw[draw=black,fill=green1] 
  (0,0) rectangle (3.5,-6);
\draw[draw=black,fill=purple1] 
  (3.5,0) rectangle (6,-6);
\draw[draw=black,fill=green2] 
  (0,-6) rectangle (3.8,-9);
\draw[draw=black,fill=blue1] 
  (3.8,-6) rectangle (6,-8);
\draw[draw=black,fill=purple1] 
  (3.8,-8) rectangle (6,-9);

\node at (1.75,-3) {Paul};
\node at (4.75,-3) {Dennis};
\node at (1.9,-7.5) {Rick};
\node at (4.9,-7) {Simon};
\node at (4.9,-8.5) {Alvin};
\end{tikzpicture}

\end{document}

enter image description here