ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Using variables and macros for styling of section title and line in table of contents
@ 2020-07-22 19:20 James Withers
  2020-07-22 19:38 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: James Withers @ 2020-07-22 19:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Dear list


I have a document with section headings which include a title, date and
reference spread over two lines with different font style and
justification, plus a slightly different text for the table of contents.


So that I can alter the styling of the section headings without having to
recode each \startsection command, I have used variables and a macro
command for the style.


This works for section 'title' and 'marking', but not for the 'list'
attribute.


The minimal working example below shows what I'm trying to do.


Best wishes and many thanks in advance.


James



\define\mytitle{\getvariable{myvar}{title}\crlf{\tfx\getvariable{myvar}{date}\hfill\getvariable{myvar}{ref}}}
\define\mylist{\getvariable{myvar}{list}---{\bf \getvariable{myvar}{date}}}

\starttext

\completecontent

\setvariables[myvar][
title={What I would like},
date={2020},
ref={Reference No 1},
list={Variation on title},
]

\startsection[title=\mytitle,list={Variation on title---{\bf 2020}}]

Contents line to look like this:

\mylist

\stopsection


\setvariables[myvar][
title={What I get},
date={2021},
ref={Reference No 2},
list={Something for the contents},
]

\startsection[title=\mytitle,list=\mylist]

Contents line to look like this:

\mylist

\stopsection
\stoptext

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

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

[-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Using variables and macros for styling of section title and line in table of contents
  2020-07-22 19:20 Using variables and macros for styling of section title and line in table of contents James Withers
@ 2020-07-22 19:38 ` Wolfgang Schuster
  2020-07-22 19:45   ` James Withers
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2020-07-22 19:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users, James Withers

James Withers schrieb am 22.07.2020 um 21:20:
> Dear list
> 
> I have a document with section headings which include a title, date and 
> reference spread over two lines with different font style and 
> justification, plus a slightly different text for the table of contents.
> 
> So that I can alter the styling of the section headings without having 
> to recode each \startsection command, I have used variables and a macro 
> command for the style.
> 
> This works for section 'title' and 'marking', but not for the 'list' 
> attribute.

The title argument works only because it is placed in the text but it 
won't work when you try to show the argument in the ToC like the list 
argument.

> The minimal working example below shows what I'm trying to do.
> 
> Best wishes and many thanks in advance.
> 
> James
> 
> \define\mytitle{\getvariable{myvar}{title}\crlf{\tfx\getvariable{myvar}{date}\hfill\getvariable{myvar}{ref}}}
> \define\mylist{\getvariable{myvar}{list}---{\bf \getvariable{myvar}{date}}}

In this case you have to use \defineexpandable to create your commands 
and enable expansion for sections.

\defineexpandable\mytitle{...}
\defineexpandable\mylist {...}

\setuphead[section][expansion=yes]

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Using variables and macros for styling of section title and line in table of contents
  2020-07-22 19:38 ` Wolfgang Schuster
@ 2020-07-22 19:45   ` James Withers
  0 siblings, 0 replies; 3+ messages in thread
From: James Withers @ 2020-07-22 19:45 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users


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

Thanks so much for such a quick reply Wolfgang

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, 22 Jul 2020 at 20:38, Wolfgang Schuster <
wolfgang.schuster.lists@gmail.com> wrote:

> James Withers schrieb am 22.07.2020 um 21:20:
> > Dear list
> >
> > I have a document with section headings which include a title, date and
> > reference spread over two lines with different font style and
> > justification, plus a slightly different text for the table of contents.
> >
> > So that I can alter the styling of the section headings without having
> > to recode each \startsection command, I have used variables and a macro
> > command for the style.
> >
> > This works for section 'title' and 'marking', but not for the 'list'
> > attribute.
>
> The title argument works only because it is placed in the text but it
> won't work when you try to show the argument in the ToC like the list
> argument.
>
> > The minimal working example below shows what I'm trying to do.
> >
> > Best wishes and many thanks in advance.
> >
> > James
> >
> >
> \define\mytitle{\getvariable{myvar}{title}\crlf{\tfx\getvariable{myvar}{date}\hfill\getvariable{myvar}{ref}}}
> > \define\mylist{\getvariable{myvar}{list}---{\bf
> \getvariable{myvar}{date}}}
>
> In this case you have to use \defineexpandable to create your commands
> and enable expansion for sections.
>
> \defineexpandable\mytitle{...}
> \defineexpandable\mylist {...}
>
> \setuphead[section][expansion=yes]
>
> Wolfgang
>

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

[-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2020-07-22 19:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 19:20 Using variables and macros for styling of section title and line in table of contents James Withers
2020-07-22 19:38 ` Wolfgang Schuster
2020-07-22 19:45   ` James Withers

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