From: Rory Molinari <context@quokka70.fastmail.fm>
To: ntg-context@ntg.nl
Subject: Adding custom key/value pairs
Date: Sat, 12 Apr 2008 12:44:16 -0700 [thread overview]
Message-ID: <2c62660f97846a8a50e04eab167dde42@quokka70.fastmail.fm> (raw)
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
___________________________________________________________________________________
next reply other threads:[~2008-04-12 19:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-12 19:44 Rory Molinari [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c62660f97846a8a50e04eab167dde42@quokka70.fastmail.fm \
--to=context@quokka70.fastmail.fm \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).