From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67157 Path: news.gmane.org!not-for-mail From: Cecil Westerhof Newsgroups: gmane.comp.tex.context Subject: Re: Macro for acronyms Date: Sat, 19 Mar 2011 05:00:47 +0100 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0203217677==" X-Trace: dough.gmane.org 1300507271 26017 80.91.229.12 (19 Mar 2011 04:01:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2011 04:01:11 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Mar 19 05:01:07 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0nLe-000519-DY for gctc-ntg-context-518@m.gmane.org; Sat, 19 Mar 2011 05:01:06 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 08501CAB36; Sat, 19 Mar 2011 05:01:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kyrrewV5fuMS; Sat, 19 Mar 2011 05:00:57 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 97DA0CAAD6; Sat, 19 Mar 2011 05:00:57 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 82A90CAAD6 for ; Sat, 19 Mar 2011 05:00:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dF+zxBA3u8F7 for ; Sat, 19 Mar 2011 05:00:43 +0100 (CET) Original-Received: from filter1-til.mf.surf.net (filter1-til.mf.surf.net [194.171.167.217]) by balder.ntg.nl (Postfix) with ESMTP id A1249CAACD for ; Sat, 19 Mar 2011 05:00:43 +0100 (CET) Original-Received: from mail-fx0-f41.google.com (mail-fx0-f41.google.com [209.85.161.41]) by filter1-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p2J40lwx011714 for ; Sat, 19 Mar 2011 05:00:48 +0100 Original-Received: by fxm18 with SMTP id 18so5511498fxm.14 for ; Fri, 18 Mar 2011 21:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=GjX8g2w26mWjzCPiobzFWthftW6O30eNUNW2BEN3OlA=; b=W0/6NOKbhAAf98Wg6O9SPEqRAUr7u2Zfx76QZZ7zN6j2qeNfpQe3ZOvCiDRNoSmKdi FND7rWiogn4GDXQ+ZVrU8KaE4lJxU+Yycg1sKAyY9baTKlVK4LB5QG8zJDE2MssEiAge H/0ITGoQ8m7y9iQ7gcFPmHiVGQI9sKL3a3cOM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=X5QtkJ4qqJ7aCyqysnS5Im0reVWU9YA3PvF/LB44QmD9f5fu1/18rI6S83MOoEEWLQ e8W6FCTd1crGjx9Wko0eemMyJqnNnzrD48POmU7YEgCgXs1bHm2z8XHSOl7GOWZdUVBK uM21MYjnZYC429llTUdIMyc/JI84HJvZTRvfY= Original-Received: by 10.223.103.72 with SMTP id j8mr2067004fao.145.1300507247252; Fri, 18 Mar 2011 21:00:47 -0700 (PDT) Original-Received: by 10.223.110.71 with HTTP; Fri, 18 Mar 2011 21:00:47 -0700 (PDT) In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.161.41; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 08EkQ0L8y - 297f166dff1b - 20110319 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.217 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:67157 Archived-At: --===============0203217677== Content-Type: multipart/alternative; boundary=001636c5bb74801763049ecdf0f0 --001636c5bb74801763049ecdf0f0 Content-Type: text/plain; charset=ISO-8859-1 2011/3/19 Aditya Mahajan > On Sat, 19 Mar 2011, Cecil Westerhof wrote: > > At the moment I have I my document: >> {\switchtobodyfont[1.25em]\bf M}ust >> >> {\switchtobodyfont[1.25em]\bf S}hould >> >> {\switchtobodyfont[1.25em]\bf C}ould >> >> {\switchtobodyfont[1.25em]\bf N}ot now >> >> But I like to have a macro for this, so I could just do: >> \Acronym{Must Should Could Not~now} >> >> Is more readable and when I want a change (for example another color for >> the >> first letter), this is much easier to implement. How should I implement >> such >> a macro? >> > > > Use recursion! > > \definestartstop > [FancyFirstLetter] > [style={\switchtobodyfont[big]\bf}, > color=red] > > \def\FancyUppercase#1% > {\dostartFancyUppercase#1\dostopFancyUppercase} > > \def\dostartFancyUppercase#1#2\dostopFancyUppercase > {\FancyFirstLetter{#1}#2} > > > \def\Acronym#1% > {\dostartAcronym#1 \dostopAcronym} > > \def\dostartAcronym#1 #2\dostopAcronym > {\doifsomething{#1} > {\FancyUppercase{#1} %space > \dostartAcronym#2 \dostopAcronym}} Almost. dostartAcronym needs a blanco line to put the words under each-other: \def\dostartAcronym#1 #2\dostopAcronym {\doifsomething{#1} {\FancyUppercase{#1} %space \dostartAcronym#2 \dostopAcronym}} -- Cecil Westerhof --001636c5bb74801763049ecdf0f0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2011/3/19 Aditya Mahajan <<= a href=3D"mailto:adityam@umich.edu">adityam@umich.edu>
On Sat, 19 Mar 2011, Cecil Westerhof wrot= e:

At the moment I have I my document:
{\switchtobodyfont[1.25em]\bf M}ust

{\switchtobodyfont[1.25em]\bf S}hould

{\switchtobodyfont[1.25em]\bf C}ould

{\switchtobodyfont[1.25em]\bf N}ot now

But I like to have a macro for this, so I could just do:
\Acronym{Must Should Could Not~now}

Is more readable and when I want a change (for example another color for th= e
first letter), this is much easier to implement. How should I implement suc= h
a macro?


Use recursion!

\definestartstop
=A0[FancyFirstLetter]
=A0[style=3D{\switchtobodyfont[big]\bf},
=A0 color=3Dred]

\def\FancyUppercase#1%
=A0{\dostartFancyUppercase#1\dostopFancyUppercase}

\def\dostartFancyUppercase#1#2\dostopFancyUppercase
=A0{\FancyFirstLetter{#1}#2}


\def\Acronym#1%
=A0{\dostartAcronym#1 \dostopAcronym}

\def\dostartAcronym#1 #2\dostopAcronym
=A0{\doifsomething{#1}
=A0 =A0 =A0{\FancyUppercase{#1} %space
=A0 =A0 =A0 \dostartAcronym#2 \dostopAcronym}}
=A0
Alm= ost. dostartAcronym needs a blanco line to put the words under each-other:<= br>\def\dostartAcronym#1 #2\dostopAcronym
=A0 {\doifsomething{#1}
=A0= =A0=A0=A0 {\FancyUppercase{#1} %space

=A0=A0=A0=A0=A0=A0 \dostartAcronym#2 \dostopAcronym}}

--
Cecil Westerhof
--001636c5bb74801763049ecdf0f0-- --===============0203217677== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============0203217677==--