ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] How to set section title based on section content?
       [not found] <1422901094.1250385.1709996503721.ref@mail.yahoo.com>
@ 2024-03-09 15:01 ` Joel via ntg-context
  2024-03-09 15:15   ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 2+ messages in thread
From: Joel via ntg-context @ 2024-03-09 15:01 UTC (permalink / raw)
  To: Mailing List for ConTeXt Users; +Cc: Joel


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

How to set section title based on section content?

I have a document that has some structures like this:

\starttext

\startsection[title={Animals}]

\event{\input knuth }

\stopsection

\startsection[title={Books}]

\event{\input knuth }

\stopsection

\stoptext

The event macro runs a bunch of conditionals, deciding which content to place inside the section. It places any one of neary 200 possible different types of content there.

Sadly when I wrote the code, I thought generic titles would be okay. Now I realize I need to be more specific, giving titles that match the content inside. I could move the section titles inside the \event macro, but it means rewriting ~200 other macros.

In other words, how do I define a section title by defining it somewhere in the content of the \event macro?

\starttext

\startsection[\whatistitle] %<-- would display "Neon Tetras"

\event{\thetitleis{Neon Tetras}\input knuth }

\stopsection

\startsection[\whatistitle] %<-- would display "Detective Stories"

\event{\thetitleis{Detective Stories}\input knuth }

\stopsection

\stoptext






[-- Attachment #1.2: Type: text/html, Size: 1453 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] 2+ messages in thread

* [NTG-context] Re: How to set section title based on section content?
  2024-03-09 15:01 ` [NTG-context] How to set section title based on section content? Joel via ntg-context
@ 2024-03-09 15:15   ` Wolfgang Schuster
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2024-03-09 15:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Joel via ntg-context

Joel via ntg-context schrieb am 09.03.2024 um 16:01:
> How to set section title based on section content?
> 
> I have a document that has some structures like this:
> 
> \starttext
> 
> \startsection[title={Animals}]
> 
> \event{\input knuth }
> 
> \stopsection
> 
> \startsection[title={Books}]
> 
> \event{\input knuth }
> 
> \stopsection
> 
> \stoptext
> 
> The event macro runs a bunch of conditionals, deciding which content to 
> place inside the section. It places any one of neary 200 possible 
> different types of content there.
> 
> Sadly when I wrote the code, I thought generic titles would be okay. Now 
> I realize I need to be more specific, giving titles that match the 
> content inside. I could move the section titles inside the \event macro, 
> but it means rewriting ~200 other macros.
> 
> In other words, how do I define a section title by defining it somewhere 
> in the content of the \event macro?
> 
> \starttext
> 
> \startsection[\whatistitle] %<-- would display "Neon Tetras"
> 
> \event{\thetitleis{Neon Tetras}\input knuth }
> 
> \stopsection
> 
> \startsection[\whatistitle] %<-- would display "Detective Stories"
> 
> \event{\thetitleis{Detective Stories}\input knuth }
> 
> \stopsection
> 
> \stoptext

When each section contains nothing except the \event command I would 
remove the section titles from the document itself and place them as 
part of the \event command.

\define[1]\Event
   {\startsection[title={#1}]
    \input{knuth}
    \stopsection}

\starttext

\Event{Neon Tetras}

\Event{Detective Stories}

\stoptext

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] 2+ messages in thread

end of thread, other threads:[~2024-03-09 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1422901094.1250385.1709996503721.ref@mail.yahoo.com>
2024-03-09 15:01 ` [NTG-context] How to set section title based on section content? Joel via ntg-context
2024-03-09 15:15   ` [NTG-context] " 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).