alternating items in an itemization
I'd like to define an itemization that has two kinds of items, representing a dialogue between two people. (One could imagine extending this to more than two.) I'd like to have something like this: \startdialogue \john What did you have for breakfast? \mary I skipped breakfast today. \john Oh, why? \mary Because I wasn't hungry. I was too distraught at what had happened the previous night. \stopdialogue The \john and \mary parts would each be their own paragaphs. The paragraphs would be colored with different text backgrounds, and joined up with one another (that is, the blocks of text representing the paragraphs for the different speakers would be adjacent to one another). I've tried doing this using \defineparagraphs, \defineframedtext, and \defineenumerations, but I can't quite get the right effect; \setupcolors[state=start] \definetextbackground[john-background][backgroundcolor=green] \definetextbackground[mary-background][backgroundcolor=red] \definestartstop[dialogue] \defineparagraphs[john][before={\starttextbackground[john-background]},after={\stoptextbackground}] \defineparagraphs[mary][before={\starttextbackground[mary-background]},after={\stoptextbackground}] Putting this before the above \start/stopdialogue snippet (suitably enclosed in \start/stoptext) gives me an error about a missing "}"; I suppose I'm overlooking something. An enumeration-based solution would be along these lines: \defineenumeration [chat] \setupenumerations [chat] [joinedup,packed] \define[0]\john{\item John: } \define[0]\may{\item Mary: } I can't figure out how to get the textbackgrounds to work here, and there's a bullet symbol at the beginning of every "dialogue paragraph", which I'd rather get rid of (and I don't want the indent between the bullet and the beginning of the text). A framed-text solution starts to come close: \defineframedtext[john][frame=off,background=color,backgroundcolor=magenta] \defineframedtext[mary][frame=off,background=color,backgroundcolor=lightred] But then the boxed paragraphs are separated from each other by some vertical whitespace. Another idea would be to use tables, but I haven't explored that yet. Any suggestions for how to render "dialogues" as above in ConTeXt? Thanks, Jesse
Am 23.05.2011 um 22:08 schrieb Jesse Alama:
I'd like to define an itemization that has two kinds of items, representing a dialogue between two people. (One could imagine extending this to more than two.) I'd like to have something like this:
\startdialogue \john What did you have for breakfast? \mary I skipped breakfast today. \john Oh, why? \mary Because I wasn't hungry. I was too distraught at what had happened the previous night. \stopdialogue
The \john and \mary parts would each be their own paragaphs. The paragraphs would be colored with different text backgrounds, and joined up with one another (that is, the blocks of text representing the paragraphs for the different speakers would be adjacent to one another).
Solution 1: \definetextbackground[john-background][frame=off,location=paragraph,backgroundcolor=green] \definetextbackground[mary-background][frame=off,location=paragraph,backgroundcolor=red] \defineenumeration [john] [ text=John: , width=3em, number=no, location=left, before={\starttextbackground[john-background]}, after=\stoptextbackground] \defineenumeration [mary][john] [ text=Mary: , before={\starttextbackground[mary-background]}, after=\stoptextbackground] \starttext \john What did you have for breakfast?\par \mary I skipped breakfast today.\par \startjohn Oh, why?\stopjohn \startmary Because I wasn't hungry. I was too distraught at what had happened the previous night.\stopmary \stoptext Solution 2: \usemodule[annotation] \definetextbackground[john-background][frame=off,location=paragraph,backgroundcolor=green] \definetextbackground[mary-background][frame=off,location=paragraph,backgroundcolor=red] \defineannotation [john] [ text=John, stopper=: , inbetween=, before={\starttextbackground[john-background]}, after={\stoptextbackground}, spacebefore=nowhite] \defineannotation [mary][john] [ text=Mary, before={\starttextbackground[mary-background]}, after={\stoptextbackground}] \starttext \john{What did you have for breakfast?} \mary{I skipped breakfast today.} \startjohn Oh, why?\stopjohn \startmary Because I wasn't hungry. I was too distraught at what had happened the previous night.\stopmary \stoptext Wolfgang
On 2011-05-24 14:16:16 +0200, Wolfgang Schuster said:
Am 23.05.2011 um 22:08 schrieb Jesse Alama:
I'd like to define an itemization that has two kinds of items, representing a dialogue between two people. (One could imagine extending this to more than two.) I'd like to have something like this:
\startdialogue \john What did you have for breakfast? \mary I skipped breakfast today. \john Oh, why? \mary Because I wasn't hungry. I was too distraught at what had happened the previous night. \stopdialogue
The \john and \mary parts would each be their own paragaphs. The paragraphs would be colored with different text backgrounds, and joined up with one another (that is, the blocks of text representing the paragraphs for the different speakers would be adjacent to one another).
Solution 1:
\definetextbackground[john-background][frame=off,location=paragraph,backgroundcolor=green] \definetextbackground[mary-background][frame=off,location=paragraph,backgroundcolor=red]
\defineenumeration
[john] [ text=John: , width=3em, number=no, location=left, before={\starttextbackground[john-background]}, after=\stoptextbackground]
\defineenumeration [mary][john] [ text=Mary: , before={\starttextbackground[mary-background]}, after=\stoptextbackground]
\starttext
\john What did you have for breakfast?\par \mary I skipped breakfast today.\par \startjohn Oh, why?\stopjohn \startmary Because I wasn't hungry. I was too distraught at what had happened the previous night.\stopmary
\stoptext
Solution 2:
\usemodule[annotation]
\definetextbackground[john-background][frame=off,location=paragraph,backgroundcolor=green]
\definetextbackground[mary-background][frame=off,location=paragraph,backgroundcolor=red] \defineannotation
[john] [ text=John, stopper=: , inbetween=, before={\starttextbackground[john-background]}, after={\stoptextbackground}, spacebefore=nowhite]
\defineannotation [mary][john] [ text=Mary, before={\starttextbackground[mary-background]}, after={\stoptextbackground}]
\starttext
\john{What did you have for breakfast?} \mary{I skipped breakfast today.} \startjohn Oh, why?\stopjohn \startmary Because I wasn't hungry. I was too distraught at what had happened the previous night.\stopmary
\stoptext
Thanks! These fit the bill. (I note, though, that in the annotation-based solution, the texts "John" and "Mary" don't show up. Otherwise the annotation solution is just what I am looking for.)
Am 24.05.2011 um 16:24 schrieb Jesse Alama:
Thanks! These fit the bill. (I note, though, that in the annotation-based solution, the texts "John" and "Mary" don't show up. Otherwise the annotation solution is just what I am looking for.)
I noticed this too and uploaded a new version (it was already fixed in my local version). Wolfgang
participants (2)
-
Jesse Alama
-
Wolfgang Schuster