[NTG-context] getting ConTeXt results back to Lua (for typesetting solutions at end of document)

Mikael P. Sundqvist mickep at gmail.com
Fri Feb 1 07:58:01 CET 2019


Hi,

this is what I learned from the list to use. I'm sorry, but the names
sound a bit Swedish, but I'm sure you can change that. This way it was
also easy to add different types like hints, answers and solutions and
get clickable letters accordingly.

/Mikael

%Test file
\setupinteraction[state=start,color=,contrastcolor=,style=]

\define[1]\problemtextmakro
 {%
  \doifreferencefoundelse{losn:\currentconstructionreference}
     {\llap{\goto{{\WORD l}}[losn:\currentconstructionreference]}\,}
     {}%
  #1
  }

\defineenumeration[problem][
referenceprefix=problem,
text=,
width=fit,
numbercommand=\problemtextmakro,
number=yes,
alternative=serried,
hang=margin,
indentnext=auto,
indenting={yes,small},
prefix=yes,
prefixsegments=chapter,
way=bychapter,
]


\defineblock[losn]
\hideblocks[losn]


\define[1]\losntextmakro
  {\doifreferencefoundelse{problem:\currentconstructionreference}
     {\bf \goto{\WORD{\in[problem:\currentconstructionreference]}}[problem:\currentconstructionreference]}
     {}
  }


\defineenumeration[losning][
referenceprefix=losn,
numbercommand=\losntextmakro,
text=,
headstyle=,
title=yes,
titlestyle=,
alternative=serried,
width=fit,
number=no,
indentnext=auto,
indenting={yes,medium},
before={\blank[halfline]},
after={\blank[halfline]},
]



\starttext

\chapter{Problems}

\startproblem[p:cont]
Show that all functions are continuous.
\stopproblem

\beginlosn
\startlosning[p:cont]
All functions are continuous\ldots
\stoplosning
\endlosn

\startproblem
This is a problem without solution
\stopproblem

\startproblem[p:diff]
Show that all functions are differentiable.
\stopproblem

\beginlosn
\startlosning[p:diff]
All functions are differentiable\ldots
\stoplosning
\endlosn


\beginlosn
\startlosning[p:diff]
This is a second solution to~\in[p:diff].\ldots
\stoplosning
\endlosn

\chapter{Solutions}

\selectblocks[losn][criterium=all]

On Fri, Feb 1, 2019 at 5:20 AM Alan Braslau <braslau.list at comcast.net> wrote:
>
> On Thu, 31 Jan 2019 22:10:40 -0500
> Sanjoy Mahajan <sanjoy at olin.edu> wrote:
>
> > Thank you, Matthias and Wolfgang, for the examples/solutions.
>
> Why not use the list mechanism?
>
> Alan
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context at 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
> ___________________________________________________________________________________


More information about the ntg-context mailing list