ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Macro for acronyms
@ 2011-03-19  2:29 Cecil Westerhof
  2011-03-19  3:08 ` Aditya Mahajan
  2011-03-19  9:22 ` Wolfgang Schuster
  0 siblings, 2 replies; 7+ messages in thread
From: Cecil Westerhof @ 2011-03-19  2:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 468 bytes --]

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?

-- 
Cecil Westerhof

[-- Attachment #1.2: Type: text/html, Size: 534 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro for acronyms
  2011-03-19  2:29 Macro for acronyms Cecil Westerhof
@ 2011-03-19  3:08 ` Aditya Mahajan
  2011-03-19  4:00   ` Cecil Westerhof
  2011-03-19  9:30   ` Wolfgang Schuster
  2011-03-19  9:22 ` Wolfgang Schuster
  1 sibling, 2 replies; 7+ messages in thread
From: Aditya Mahajan @ 2011-03-19  3:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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}}

\starttext
\loggingall
\Acronym{Must Should Could Not~now}
\stoptext

Aditya
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro for acronyms
  2011-03-19  3:08 ` Aditya Mahajan
@ 2011-03-19  4:00   ` Cecil Westerhof
  2011-03-19  4:37     ` Aditya Mahajan
  2011-03-19  9:30   ` Wolfgang Schuster
  1 sibling, 1 reply; 7+ messages in thread
From: Cecil Westerhof @ 2011-03-19  4:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1313 bytes --]

2011/3/19 Aditya Mahajan <adityam@umich.edu>

> 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

[-- Attachment #1.2: Type: text/html, Size: 1853 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro for acronyms
  2011-03-19  4:00   ` Cecil Westerhof
@ 2011-03-19  4:37     ` Aditya Mahajan
  2011-03-19  4:54       ` Cecil Westerhof
  0 siblings, 1 reply; 7+ messages in thread
From: Aditya Mahajan @ 2011-03-19  4:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sat, 19 Mar 2011, Cecil Westerhof wrote:

> 2011/3/19 Aditya Mahajan <adityam@umich.edu>
>
>> 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:

Better to use an explicit \blank (A blank space is equal to \par, and can 
give funny results when you change indenting)

> \def\dostartAcronym#1 #2\dostopAcronym
>  {\doifsomething{#1}
>     {\FancyUppercase{#1} %space
.       \blank% addied this
>       \dostartAcronym#2 \dostopAcronym}}
>

Aditya
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro for acronyms
  2011-03-19  4:37     ` Aditya Mahajan
@ 2011-03-19  4:54       ` Cecil Westerhof
  0 siblings, 0 replies; 7+ messages in thread
From: Cecil Westerhof @ 2011-03-19  4:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1012 bytes --]

2011/3/19 Aditya Mahajan <adityam@umich.edu>

> \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:
>>
>  At the moment I have I my document:
>
> Better to use an explicit \blank (A blank space is equal to \par, and can
> give funny results when you change indenting)


Is not the same. With a blank line the next word begins on a new line. When
using \blank there is also vertical whitespace between the words. But I
think I like it. So that is good. ;-}

-- 
Cecil Westerhof

[-- Attachment #1.2: Type: text/html, Size: 1564 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro for acronyms
  2011-03-19  2:29 Macro for acronyms Cecil Westerhof
  2011-03-19  3:08 ` Aditya Mahajan
@ 2011-03-19  9:22 ` Wolfgang Schuster
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2011-03-19  9:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 19.03.2011 um 03:29 schrieb Cecil Westerhof:

> 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?


\definestartstop[Acronym][style=\bfa]

\starttext

\starttabulate[|lh{\Acronym}|]
\HC {M}ust    \NC\NR
\HC {S}hould  \NC\NR
\HC {C}ould   \NC\NR
\HC {N}ot now \NC\NR
\stoptabulate

\startlines
\Acronym{M}ust
\Acronym{S}hould
\Acronym{C}ould
\Acronym{N}ot now
\stoplines

\stoptext

Wolfgang

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro for acronyms
  2011-03-19  3:08 ` Aditya Mahajan
  2011-03-19  4:00   ` Cecil Westerhof
@ 2011-03-19  9:30   ` Wolfgang Schuster
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2011-03-19  9:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 19.03.2011 um 04:08 schrieb Aditya Mahajan:

> \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}}

\def\Acronym#1%
  {\startpacked
   \processseparatedlist[#1][ ]\doAcronym
   \stoppacked}

\def\doAcronym#1%
  {\getfirstcharacter{#1}%
   {\FancyFirstLetter\firstcharacter}\remainingcharacters\par}

Wolfgang

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-19  9:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-19  2:29 Macro for acronyms Cecil Westerhof
2011-03-19  3:08 ` Aditya Mahajan
2011-03-19  4:00   ` Cecil Westerhof
2011-03-19  4:37     ` Aditya Mahajan
2011-03-19  4:54       ` Cecil Westerhof
2011-03-19  9:30   ` Wolfgang Schuster
2011-03-19  9:22 ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).