ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Define a new command that inherits from multiple other command options
@ 2024-04-25  8:24 ai2472206007
  2024-04-26 20:31 ` [NTG-context] " Bruce Horrocks
  2024-04-27  8:01 ` Wolfgang Schuster
  0 siblings, 2 replies; 5+ messages in thread
From: ai2472206007 @ 2024-04-25  8:24 UTC (permalink / raw)
  To: ntg-context

hi!

I'm new to ConTeXt. I want to define a command with sidenote function. This [setupsidenote] command inherits the options of [setupmargindata], [setupcounter] and [setupframed]. just like [setupenumeration] inherits the option of [setupcounter].

I've defined the following sidenote command by searching, and I know how to define a new option for it. But what I don't know is how to get it to inherit the options of other commands and perform these features correctly.

Any clue is warmly welcome.

```
% macros=mkvi
\unprotect
\installnamespace          {sidenote}
\installcommandhandler \????sidenote  {sidenote}  \????sidenote
\setupsidenote[
               align=,
               conversion=n,
               way=bytext,
               style=,
]

\definecounter    [SidenoteMarkNumber] [prefix=no]
\definemargindata [SidenoteContent]    [outer]
                  [margin=margin,width=\outermarginwidth]
\setupmargindata  [SidenoteContent]    [stack=yes,style=\it]
\def\sidenotemark{\rawcountervalue[SidenoteMarkNumber]}
\def\convertsidenotemark#1{\high{\convertnumber{#1}{\sidenotemark}}}
\def\sidenote{\dosingleempty\dosidenote}
\def\dosidenote[#1]#2{%
    \getparameters[SMsidenote]
                  [align=\sidenoteparameter{align},
                  conversion=\sidenoteparameter{conversion},
                  way=\sidenoteparameter{way},
                   #1]%
 \setupcounter    [SidenoteMarkNumber] [#1]
 \incrementcounter[SidenoteMarkNumber]
 \convertsidenotemark{\SMsidenoteconversion}% mark in text
 \SidenoteContent[#1]{\setscript[hanzi]\setup[\SMsidenotealign]%
                      \convertsidenotemark{\SMsidenoteconversion}% mark with note
                  #2
}}
\protect
\starttext
天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。寒来暑往,秋收冬\sidenote[align=flushleft] {天地玄黄,宇宙洪荒。}
\stoptext
```
___________________________________________________________________________________
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-04-28 12:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25  8:24 [NTG-context] Define a new command that inherits from multiple other command options ai2472206007
2024-04-26 20:31 ` [NTG-context] " Bruce Horrocks
2024-04-27  2:44   ` ai2472206007
2024-04-27  8:01 ` Wolfgang Schuster
2024-04-28 12:29   ` ai2472206007

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