ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Prefix the text in an enumeration.
@ 2024-06-13 11:41 Gerion Entrup
  2024-06-13 14:31 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Gerion Entrup @ 2024-06-13 11:41 UTC (permalink / raw)
  To: ntg-context


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

Hi,

is there a way to automatically prefix the text body in an enumeration?

Consider this example:
```
\defineenumeration[question][
	alternative=top,
	text=Question,
	title=yes,
	titleleft=,
	titleright=,
	right={:},
	headstyle=bold,
]

\starttext

Some text:

\startquestion[title={How long does a loop last?}]
\bold{Answer:} For a while.
\stopquestion

\stoptext
```

I'd like to have the `\bold{Answer:}` automatically. So for example something like this:
```
\defineenumeration[question][
	alternative=top,
	text=Question,
	title=yes,
	titleleft=,
	titleright=,
	right={:},
	headstyle=bold,
	prefix={\bold{Answer:}},
]

\starttext

Some text:

\startquestion[title={How long does a loop last?}]
For a while.
\stopquestion

\stoptext
```

I tried to misuse `inbetween` for that but `alternative=top` seems to make a (not modifiable space) between the heading and the text body.

Best
Gerion 

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Prefix the text in an enumeration.
  2024-06-13 11:41 [NTG-context] Prefix the text in an enumeration Gerion Entrup
@ 2024-06-13 14:31 ` Wolfgang Schuster
  2024-06-14  9:01   ` Gerion Entrup
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2024-06-13 14:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Gerion Entrup

Gerion Entrup schrieb am 13.06.2024 um 13:41:
> Hi,
> 
> is there a way to automatically prefix the text body in an enumeration?
> 
> Consider this example:
> ```
> \defineenumeration[question][
> 	alternative=top,
> 	text=Question,
> 	title=yes,
> 	titleleft=,
> 	titleright=,
> 	right={:},
> 	headstyle=bold,
> ]
> 
> \starttext
> 
> Some text:
> 
> \startquestion[title={How long does a loop last?}]
> \bold{Answer:} For a while.
> \stopquestion
> 
> \stoptext
> ```
> 
> I'd like to have the `\bold{Answer:}` automatically. So for example something like this:
> ```
> \defineenumeration[question][
> 	alternative=top,
> 	text=Question,
> 	title=yes,
> 	titleleft=,
> 	titleright=,
> 	right={:},
> 	headstyle=bold,
> 	prefix={\bold{Answer:}},
> ]
> 
> \starttext
> 
> Some text:
> 
> \startquestion[title={How long does a loop last?}]
> For a while.
> \stopquestion
> 
> \stoptext
> ```
> 
> I tried to misuse `inbetween` for that but `alternative=top` seems to make a (not modifiable space) between the heading and the text body.

Use the \setupparagraphintro command to set the text which should appear 
at the start of the question.

%%%% begin example
\startsetups[question:intro]
   \setupparagraphintro[first][\bold{Answer:} ]
   \blank
\stopsetups

\defineenumeration[question][
	alternative=top,
	text=Question,
	title=yes,
	titleleft=,
	titleright=,
	right={:},
	headstyle=bold,
   inbetween=\setup{question:intro},
]

\starttext

Some text:

\startquestion[title={How long does a loop last?}]
For a while.
\stopquestion

\stoptext
%%%% end example

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Prefix the text in an enumeration.
  2024-06-13 14:31 ` [NTG-context] " Wolfgang Schuster
@ 2024-06-14  9:01   ` Gerion Entrup
  2024-06-14  9:51     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Gerion Entrup @ 2024-06-14  9:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Wolfgang Schuster


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

Am Donnerstag, 13. Juni 2024, 16:31:58 MESZ schrieb Wolfgang Schuster:
> \startsetups[question:intro]
>    \setupparagraphintro[first][\bold{Answer:} ]
>    \blank
> \stopsetups
> 
> \defineenumeration[question][
>         alternative=top,
>         text=Question,
>         title=yes,
>         titleleft=,
>         titleright=,
>         right={:},
>         headstyle=bold,
>    inbetween=\setup{question:intro},
> ]
> 
> \starttext
> 
> Some text:
> 
> \startquestion[title={How long does a loop last?}]
> For a while.
> \stopquestion
> 
> \stoptext

Thank you. That works well for this case.

I have a follow up question. I tried to additionally set a titledistance and reproduce that for the "Answer:"-part.
ConTeXt then introduces a mysterious newline.

See this example:
```
\definehspace[dist][1em]
\startsetups[question:intro]
   \setupparagraphintro[first][\bold{Answer:}\hspace[1em]]
   \blank
\stopsetups

\defineenumeration[question][
        alternative=top,
        text=Question,
        title=yes,
        titleleft=,
        titledistance=1em,
        titleright=,
        right={:},
        headstyle=bold,
   inbetween=\setup{question:intro},
]

\starttext

Some text:

\startquestion[title={How long does a loop last?}]
For a while.
\stopquestion

\stoptext
```

Gerion

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Prefix the text in an enumeration.
  2024-06-14  9:01   ` Gerion Entrup
@ 2024-06-14  9:51     ` Wolfgang Schuster
  2024-06-14 13:59       ` Gerion Entrup
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2024-06-14  9:51 UTC (permalink / raw)
  To: Gerion Entrup; +Cc: mailing list for ConTeXt users

Gerion Entrup schrieb am 14.06.2024 um 11:01:
> Am Donnerstag, 13. Juni 2024, 16:31:58 MESZ schrieb Wolfgang Schuster:
>> \startsetups[question:intro]
>>     \setupparagraphintro[first][\bold{Answer:} ]
>>     \blank
>> \stopsetups
>>
>> \defineenumeration[question][
>>          alternative=top,
>>          text=Question,
>>          title=yes,
>>          titleleft=,
>>          titleright=,
>>          right={:},
>>          headstyle=bold,
>>     inbetween=\setup{question:intro},
>> ]
>>
>> \starttext
>>
>> Some text:
>>
>> \startquestion[title={How long does a loop last?}]
>> For a while.
>> \stopquestion
>>
>> \stoptext
> 
> Thank you. That works well for this case.
> 
> I have a follow up question. I tried to additionally set a titledistance and reproduce that for the "Answer:"-part.
> ConTeXt then introduces a mysterious newline.
> 
> See this example:
> 
> \definehspace[dist][1em]
> \startsetups[question:intro]
>     \setupparagraphintro[first][\bold{Answer:}\hspace[1em]]
>     \blank
> \stopsetups

You need 2 changes for \setupparagraphintro:

1. Change the argument of \hspace to "dist" because the commands accepts 
only keywords and everything else (even a valid length) is ignored and 
results in a horizontal skip of 0pt.

2. You have to add curly braces around the content when the content 
includes square brackets because nesting of optional arguments isn't 
supported yet.

The correct version of the one above is:

\startsetups[question:intro]
    \setupparagraphintro[first][{\bold{Answer:}\hspace[dist]}]
    \blank
\stopsetups

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Prefix the text in an enumeration.
  2024-06-14  9:51     ` Wolfgang Schuster
@ 2024-06-14 13:59       ` Gerion Entrup
  0 siblings, 0 replies; 5+ messages in thread
From: Gerion Entrup @ 2024-06-14 13:59 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users


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

Am Freitag, 14. Juni 2024, 11:51:28 MESZ schrieb Wolfgang Schuster:
> Gerion Entrup schrieb am 14.06.2024 um 11:01:
> > Am Donnerstag, 13. Juni 2024, 16:31:58 MESZ schrieb Wolfgang Schuster:
> >> \startsetups[question:intro]
> >>     \setupparagraphintro[first][\bold{Answer:} ]
> >>     \blank
> >> \stopsetups
> >>
> >> \defineenumeration[question][
> >>          alternative=top,
> >>          text=Question,
> >>          title=yes,
> >>          titleleft=,
> >>          titleright=,
> >>          right={:},
> >>          headstyle=bold,
> >>     inbetween=\setup{question:intro},
> >> ]
> >>
> >> \starttext
> >>
> >> Some text:
> >>
> >> \startquestion[title={How long does a loop last?}]
> >> For a while.
> >> \stopquestion
> >>
> >> \stoptext
> > 
> > Thank you. That works well for this case.
> > 
> > I have a follow up question. I tried to additionally set a titledistance and reproduce that for the "Answer:"-part.
> > ConTeXt then introduces a mysterious newline.
> > 
> > See this example:
> > 
> > \definehspace[dist][1em]
> > \startsetups[question:intro]
> >     \setupparagraphintro[first][\bold{Answer:}\hspace[1em]]
> >     \blank
> > \stopsetups
> 
> You need 2 changes for \setupparagraphintro:
> 
> 1. Change the argument of \hspace to "dist" because the commands accepts 
> only keywords and everything else (even a valid length) is ignored and 
> results in a horizontal skip of 0pt.

Hrmm, this was a typo.

> 
> 2. You have to add curly braces around the content when the content 
> includes square brackets because nesting of optional arguments isn't 
> supported yet.

Thanks for the help, that was the missing part.

> 
> The correct version of the one above is:
> 
> \startsetups[question:intro]
>     \setupparagraphintro[first][{\bold{Answer:}\hspace[dist]}]
>     \blank
> \stopsetups
> 
> Wolfgang
> 

Gerion


[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-06-14 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-13 11:41 [NTG-context] Prefix the text in an enumeration Gerion Entrup
2024-06-13 14:31 ` [NTG-context] " Wolfgang Schuster
2024-06-14  9:01   ` Gerion Entrup
2024-06-14  9:51     ` Wolfgang Schuster
2024-06-14 13:59       ` Gerion Entrup

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