Wrapping Text in Rounded Corners ColorBox in LaTeX with TikZ and PGF
by Alessandro
How the heck do we make a text box with a color background have its corners rounded? I wondered.
In images, how do we make the transition from the first screenshot below to the second, and maybe even to the third one?
Turns out the answer given from google’s results is more complicated than life (and LaTeX) requires, because, at least given my poor knowledge of LaTeX, \ovalbox and \oval commands don’t necessarily play nice with colours are overall less flexible than the TikZ package.
Now a word of warning: using TikZ for this purpose is a bit like using an atomic bomb to kill a bug, nonetheless using it may entice yourself (and me) to learn it more extensively and exploit it for its other much more powerful applications.
So let us get started with some quick code: it’ll only take a few lines to get our result.
Here’s the preamble:
\documentclass[10pt]{article} \usepackage{tikz} %symbols - the ones you see on the left of the email and of the phone \usepackage{bbding} %\usepackage{hyperref} \definecolor{shade}{HTML}{D4D7FE} %light blue shade
I am currently having an issue compiling with XeLaTeX and getting hyperlinks to work, so that is why the hyperlink package is commented out, and the email will not be enclosed in the \href command.
I am looking into the issue though, and will update the post when a solution is found: unfortunately I am no expert of LaTeX and even less of PGF and TikZ.
After the preamble, we begin the document and start the picture which is encapsulated by the tikzpicture environment:
\begin{document} %\begin{tikzpicture} % \node [fill=red,rounded corners=5pt] % {\href{foo}{ bar bar bar}}; %\end{tikzpicture} \begin{tikzpicture} \node [fill=shade,rounded corners=5pt] { \begin{tabular}{c|l} & Born in Wonderland, Italy July 3, 1912 \\ \raisebox{-3pt}{\Phone} & +39 123 456789\\ \raisebox{-3pt}{\Envelope} & einstein.einstein@gmail.com \end{tabular} }; \end{tikzpicture} \end{document}
This will produce the second screenshot.
The code is mostly self-explanatory, just remember that you need to define the shade color and the symbols are available if you load the bbding package.
The commented out part at the beginning will show you the problem of the hyperlinks I mentioned before.
Anyone able to hack it so it works with XeLaTeX? Let me know.
For the moment you can enjoy the two-column CV with a rounded corners box, if you like it.
Related posts:




