Changes

Jump to navigation Jump to search
2,294 bytes added ,  10:22, 10 February 2011
Created page with "In ConTeXt it is possible to use the Tikz module to create « speech bubbles ». Here are two ways of doing this: the first one works under mkii and mkiv, while the second one ne..."
In ConTeXt it is possible to use the Tikz module to create « speech bubbles ». Here are two ways of doing this: the first one works under mkii and mkiv, while the second one needs the Annotation module written by Wofgang Schuster who wrapped the Tikz commands in ConTeXt macros in the code below.

<texcode>

\usemodule[tikz]
\usetikzlibrary[shapes.callouts]

\setupbodyfont[bookman]

\setupTEXpage[offset=1em]

\starttext

\startTEXpage
\starttikzpicture[remember picture]
\node[ellipse callout, draw] (node:ref) {Hi there!};
\stoptikzpicture
\stopTEXpage

\startTEXpage
\starttikzpicture[remember picture]
\node[cloud callout, draw] (node:ref) {Hallo!};
\stoptikzpicture
\stopTEXpage

\startTEXpage
\starttikzpicture
\node[cloud callout, cloud puffs=15, aspect=2.5, cloud puff arc=120,
shading=ball,text=white] {\bf Imagine\dots};
\stoptikzpicture
\stopTEXpage

\startTEXpage
\starttikzpicture[remember picture, note/.style={rectangle callout, fill=#1}]
\draw [help lines] grid(3,2);
\node [note=red!50, callout relative pointer={(0,1)}] at (3,1) {Relative position};
\node [note=blue!50, callout absolute pointer={(0,1)}] at (1,0) {Absolute position};
\node [note=green!50, ellipse callout, opacity=.5, overlay, callout absolute pointer={(hallo.south)}] at (1,2) {Outside};
\stoptikzpicture
\stopTEXpage

\stoptext
</texcode>

In the above example, you can leave out the \startTEXpage and \stopTEXpage, and use the pictures and you wish in your text.

The second example is as follows:

<texcode>

\usemodule[tikz,annotation]
\usetikzlibrary[shapes.callouts]

\define[2]\SpeechbubbleCommand
{\starttikzpicture[remember picture]
\node[rectangle callout, draw] (node:ref) {\framedtext[width=fit,frame=off]{#2}};
\stoptikzpicture}

\defineannotation
[speechbubble]
[alternative=command,
command=\SpeechbubbleCommand]

\starttext

\speechbubble{Hello!}

\startspeechbubble
\input ward
\stopspeechbubble

\stoptext
</texcode>

As said before the above code needs mkiv functionalities (due to the usage of the Annotation module). Indeed you can change some of Tikz commands in the above defintions, for instance change the command
<texcode>
\node[rectangle callout, draw]
</texcode>
into
<texcode>
\node[cloud callout, draw]
</texcode>
to get other bubble shapes.
106

edits

Navigation menu