# Quotes with speech balloons

I looking for a way to do that with TikZ :

But I have no idea how to do this quote style.

\begin{sballoonquote}{\linewidth}{r}{color}{Donald Knuth}
An algorithm must be seen to be believed.
\end{sballoonquote}


Produce a ragged-right rounded quote, a sballoonquote* do the same but non-rounded. How can I do this. Someone have a solution ?

-
–  Alan Munn Jul 3 '12 at 15:36
Welcome to TeX.SE. If the linked question does not provide an adequate solution, please edit the question to add an explanation. –  Peter Grill Jul 3 '12 at 17:54
I don't really know how to make the shape and make a final environment. And I found the linked question not very useful for my own case. –  David Jul 3 '12 at 20:36
@David sorry for suggesting the duplicate to quickly. It's not so trivial to adapt the linked question to your problem, although the ideas are similar. The question has now been reopened. –  Alan Munn Jul 4 '12 at 12:14
Thanks for your solutions guys :) But the idea in my mind is like that : link. Can work on the right and left sides. For conversation style or for even-odd pages. @Alan : How can I use differents colors like on the Tom's solution ? I found the way for the rounded boxes. –  David Jul 4 '12 at 15:40

Here's a solution that is based almost completely on the great answer by percusse posted here.

Simple speech bubbles, arrows or balloon like shapes in beamer

I've only implemented this as a command with the arrow pointing in one direction, but this should be enough to get you going.

\documentclass{article}
\usepackage{kantlipsum} % for dummy text
\usepackage{calc}
\newlength{\calloutheight}
\newlength{\calloutoffset}
\newlength{\quoteheight}
\setlength{\calloutoffset}{5ex}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.callouts}
\newcommand{\calloutquote}[3][.95\textwidth]{%
% First we measure the height of the quote
% Then add the offset for the author
% The callout height is used to position to callout
% The quote height is used to reserve enough space within
% the text.  This code base almost entirely on percusse's
\setbox0=\vbox{\parbox[b]{#1}{#3}}
\setlength{\calloutheight}{\ht0+\calloutoffset}
\setlength{\quoteheight}{\calloutheight+2\baselineskip}
\par\vspace*{\quoteheight}
\noindent\hfil
\tikz[remember picture]{
\node [anchor=base,inner sep=0,outer sep=0,
text width=#1,align=center] (#2) {#2};
\node[anchor=base,overlay,rectangle callout,
callout relative pointer={(-0.3cm,-0.7cm)},
fill=blue!30,text width=#1,align=justify]
at ($(#2.north)+(0,\calloutheight)$) {#3};}
}

\begin{document}
Some text.
\calloutquote{Immanuel didn't really say this}{\kant[1]}

This is some text.
\calloutquote[.5\textwidth]{And he didn't say this either}{\kant[2]}
\end{document}


-

I prefer to use pgfkeys because it's more easy to list the arguments and to add some options.

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}

\pgfkeys{%
/calloutquote/.cd,
width/.code                   =  {\def\calloutquotewidth{#1}},
position/.code                =  {\def\calloutquotepos{#1}},
author/.code                  =  {\def\calloutquoteauthor{#1}},
/calloutquote/.unknown/.code   =  {\let\searchname=\pgfkeyscurrentname
\pgfkeysalso{\searchname/.try=#1,
/tikz/\searchname/.retry=#1},\pgfkeysalso{\searchname/.try=#1,
/pgf/\searchname/.retry=#1}}
}

\newcommand\calloutquote[2][]{%
\pgfkeys{/calloutquote/.cd,
width               = 5cm,
position            = {(0,-1)},
author              = {}}
\pgfqkeys{/calloutquote}{#1}
\node [rectangle callout,callout relative pointer={\calloutquotepos},text width=\calloutquotewidth,/calloutquote/.cd,
#1] (tmpcall) at (0,0) {#2};
\node at (tmpcall.pointer){\calloutquoteauthor};
}

\begin{document}
\begin{tikzpicture}
\calloutquote[author=D. Knuth,width=3cm,position={(1,-1)},fill=red!30,rounded corners]{An algorithm must be seen to be believed.}
\end{tikzpicture}

\begin{tikzpicture}
\calloutquote[author=D. Knuth,width=0.5*\linewidth,position={(0,-1)},fill=green!30,rounded corners]{An algorithm must be seen to be believed.}
\end{tikzpicture}

\begin{tikzpicture}
\calloutquote[author=D. Knuth,width=5cm,position={(-1,-1)},fill=blue!30,ultra thick,draw,inner sep=12pt]{An algorithm must be seen to be believed.}
\end{tikzpicture}
\end{document}


-
Thanks! This is a very nice example of how to use pgfkeys. –  Alan Munn Jul 4 '12 at 17:33

\documentclass[parskip,10pt]{scrartcl}
\usepackage[margin=10mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes,fit,backgrounds}
\usepackage{lipsum}
\usepackage{kerkis}
\usepackage{xifthen}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\newcommand{\bubble}[6]% name, content, color, align, inner sep, width
{   \ifthenelse{\equal{r}{#4}\OR\equal{c}{#4}}{\hfill}{}
\begin{tikzpicture}
\node[text width=\the\textwidth*#6, below right](#1){#2};
\begin{pgfonlayer}{background}
\node[fit=(#1),inner sep=#5,rectangle callout,rounded corners=3pt,draw,fill=#3,overlay] {};
\end{pgfonlayer}
\end{tikzpicture}
\ifthenelse{\equal{l}{#4}\OR\equal{c}{#4}}{\hfill\phantom{}\\[5mm]}{\\[5mm]}
}

\begin{document}

\bubble{first}{\lipsum[1]}{blue!50}{l}{3mm}{0.9}

\bubble{second}{\lipsum[2]}{red!50}{r}{3mm}{0.7}

\bubble{second}{\lipsum[3]}{green!50}{c}{3mm}{0.5}

\bubble{third}{\lipsum[4]}{blue!50}{l}{3mm}{0.9}

\bubble{fouth}{\lipsum[5]}{red!50}{r}{3mm}{0.8}

\bubble{fouth}{\lipsum[6]}{green!50}{r}{3mm}{1.0}

\end{document}


-