ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Adding custom key/value pairs
@ 2008-04-12 19:44 Rory Molinari
  2008-04-13 10:08 ` Taco Hoekwater
  0 siblings, 1 reply; 14+ messages in thread
From: Rory Molinari @ 2008-04-12 19:44 UTC (permalink / raw)
  To: ntg-context

Hi,

I'm new to ConTeXt and decided to teach myself a bit by resetting my 
old thesis (originally done, many years ago, in LaTeX).  As the purpose 
is to teach myself ConTeXt rather than just have an electronic version 
of the thesis I decided to try to do things the "right" way.

So, in setting the title page I followed the pattern shown on 
Contextgarden here: http://wiki.contextgarden.net/Document_Titles.  
That page shows how to define a nice \placetitle command with an 
associated \setuptitle which allows us to define values for title, 
subject, and date.  However, I want also to be able to define values 
for degree, subject, and committee (to follow the school-standard LaTeX 
style file I had from all those years ago).  I can't work out how to do 
this.

Simply using a variable like \c!degree (to match the \c!title I found 
in the example) doesn't work, as ConTeXt doesn't know about such a 
control sequence.  I was quite puzzled for a while but then it dawned 
on me that the example I found on contextgarden works because the keys 
it uses (for key/value pairs) are ones that are already defined in the 
ConTeXt system: title, subject, date.  My attempt fails because the 
system doesn't know about degree, subject, and committee.

I tried defining a new variable with startvariables, but that didn't 
appear to help.

So, my question: what do I need to do to define a new key that can be 
used in a key/value pair?


Here's an example of what I tried:


\startvariables all
   degree: degree
\stopvariables

\definesystemvariable{tp}  % title page

\def\setuptitlepage{\dodoubleempty\dosetuptitlepage}

\def\dosetuptitlepage[#1][#2]%
   {\ifsecondargument
      \dodosetuptitlepage[#1][#2]%
    \else
      \dodosetuptitlepage[\v!content][#1]%
    \fi}

\def\dodosetuptitlepage[#1][#2]%
   {\def\dododosetuptitlepage##1%
      {\getparameters[\??tp##1][#2]}%
    \processcommalist[#1]\dododosetuptitlepage}

\def\placetitlepage
   {\startalignment[\v!middle]
     \doattributes{\??tp\c!degree}\c!style\c!color\@@tpcontentdegree
     \stopalignment}

\setuptitlepage
   [\c!degree]
   [\c!style=\tfa,\c!color=]

\startfrontmatter
\placetitlepage
\stopfrontmatter

\starttext
\stoptext


Cheers,
Rory

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2008-04-17  8:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-12 19:44 Adding custom key/value pairs Rory Molinari
2008-04-13 10:08 ` Taco Hoekwater
2008-04-13 17:37   ` Rory Molinari
2008-04-14  9:56     ` Olivier Guéry
2008-04-14 10:18       ` Wolfgang Schuster
2008-04-14 10:34         ` Olivier Guéry
2008-04-14 10:58           ` Wolfgang Schuster
2008-04-14 11:20             ` Taco Hoekwater
2008-04-14 11:53               ` Wolfgang Schuster
2008-04-14 16:11               ` Aditya Mahajan
2008-04-15 10:56                 ` Wolfgang Schuster
2008-04-15 15:34                   ` Aditya Mahajan
2008-04-17  8:24                     ` Wolfgang Schuster
2008-04-17  8:42                       ` Taco Hoekwater

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).