# ConTeXt change number formatting in \defineenumeration

When using \setupenumeration in ConTeXt, is there an equivalent to \setupitemgroup's norepeat flag? I would like my custom enumeration sub levels to follow the pattern of

1)
a)
b)
i)
ii)
c)
2)


But haven't been able to remove the leading parent group numbers, making the format look like

1)
1.a)
1.b)
1.b.i)
1.b.ii)
1.c)
2)


I've tried to use the parameters inhereted from \setupcounter but so far, none of them have had any effect.

EDIT: I've added a simplified form of the code i've been working with below. I'm looking to use the \defineenumeration commands as opposed to the itemize ones. Though maybe im confused about their application?

\startluacode
userdata = userdata or {}

function userdata.getQval(weight, question)
qVals[#qVals+1]=tonumber(weight)
tot = table.reduce(qVals, sumT)
context("(" .. weight .. " points) " .. question .. " " .. tot)
end
\stopluacode

\def\getQuestionVal#1#2{%
\ctxlua{userdata.getQval([==[#1]==], [==[#2]==])}%
}

\definestructureconversionset[questionConversion][n,a,r][n]
\defineseparatorset[none][][]

\setupitemgroup[questionEnumeration][1][norepeat]
\setupitemgroup[questionEnumeration][2][norepeat]
\defineenumeration[questionEnumeration]
[
text={},
title=yes,
titlestyle=bold,
titleright={},
titleleft={},
indenting=always,
indentnext=yes,
aligntitle=yes,
stopper={)},
numberseparatorset=none,
numberconversionset=questionConversion,
]

\def\question#1#2#3{%
\startquestionEnumeration[title=\getQuestionVal{#1}{#2}]
\doifmodeelse{key}{\startcolor[red]#3\stopcolor}{\blank[#1*2em]}
\stopquestionEnumeration
}

\def\subquestion#1#2#3{%
\startsubquestionEnumeration[title=\getQuestionVal{#1}{#2}]
\doifmodeelse{key}{\startcolor[red]#3\stopcolor}{\blank[#1*2em]}
\stopsubquestionEnumeration
}

\def\subsubquestion#1#2#3{%
\startsubsubquestionEnumeration[title=\getQuestionVal{#1}{#2}]
\doifmodeelse{key}{\startcolor[red]#3\stopcolor}{\blank[#1*2em]}
\stopsubsubquestionEnumeration
}

\starttext
%\enablemode[key]

\question{3}{This is the question}{this is its sol}
\question{7}{Another question}{another sol}
\question{5}{and another}{yet another sol}
\stoptext

• My mistake, code added! – anthsts Oct 27 '18 at 1:33
• Thanks to Wolfgang Schuster, you have a conceptual answer with \defineenumeration. Does that address what you're looking for, or do you need something also using some luacode? Trying to simulate your Question database is an issue. Also, there's a "mode" variable on which presentation of the {sol} part shows or not. Without the "mode" variable, possible to simulate (but not yet part of the MWE), it's possible to produce (n points) The Question is (n) with a Question number per level. – Saphar Koshet Oct 27 '18 at 13:43
• Yes, the answer provided by Wolfgang Schuster was what i was looking for. For this portion I wasn't looking to use lua code. Sorry for the confusion, when i was making up the MWE i wasn't as careful as i should've been when trying to delete extraneous parts of the code, I hadn't realized i'd broken it. – anthsts Oct 27 '18 at 15:12
• Very good. There are a couple of options. One is to edit the MWE to clean that up a bit. The other is to leave it, and let me address what I can given the original MWE. I'll be doing modifications to that segment, given the need to define a few things. But, since you've sorta changed horses midstream, here, it may be valuable to someone to see how what Wolfgang Schuster has provided as applied in the context of the original MWE. It may still be a few minutes, but I'm pretty close to getting that accomplished. – Saphar Koshet Oct 27 '18 at 15:53

You can control the numbers which are shown for each enumeration level with the numbersegments key.

\defineconversionset [question] [n,a,r] [n]

\defineenumeration [question] [text=]

\setupenumeration
[question]
[numberconversionset=question,
numberstopper=),
alternative=serried,

\setupenumeration
[subquestion]
[numbersegments=2,
margin=2em]

\setupenumeration
[subsubquestion]
[numbersegments=3,
margin=4em]

\starttext

\startquestion
First level question.
\stopquestion

\startsubquestion
Second level question.
\stopsubquestion

\startsubsubquestion
Third level question.
\stopsubsubquestion

\stoptext


I expect that the assistance page you may be looking for is here.

\defineitemgroup[myenum][levels=3]

\setupitemgroup[myenum][1][n][right=), stopper=]
\setupitemgroup[myenum][2][a][right=), stopper=]
\setupitemgroup[myenum][3][i][right=), stopper=]

\starttext
This is our item list:

\startmyenum
\item ...          % 1
\startmyenum
\item ...      % 1.a without the 1.
\item ...   %  1.b without the 1.
\startmyenum
\item ...  % 1.a.i without the 1.a
\item ...   % 1.a.ii without the 1.a
\stopmyenum
\item ...      % 1.c without the 1.
\stopmyenum
\item ...          % 2
\stopmyenum

\stoptext


Here's what this produces:

• Sorry, i've added code to clarify what I was asking for. I was trying to use the \defineenumeration commands/environment – anthsts Oct 27 '18 at 1:35
• That can make a difference sometimes. :) Let's see what we've got. – Saphar Koshet Oct 27 '18 at 10:09

The website's threshold question for my adding another Answer is whether to add one or edit the original. Since basic enum in ConTeXt is related but distinct, I hope by leaving the original answer, the differences are all the more clear to those with similar questions.

The main idea comes down to this. There's an autoformatting for numbering, and it includes all the preceding levels, thus, 1, 1.a, 1.a.i, and etc. To avoid the whole numbering format, one has to customize the numbering per level, which is Wolfgang Schuster's point.

Helpful for ConTeXt enumeration is Hans Hagel's ConTeXt -- The Manual § 10.3 (pp.228-30)

In what's provided below, the luacode segment of the original MWE is modified (significantly). The original code will make sense on the OP's system, but without that database and related code in context, "none" of the variables is defined, rendering simulation necessary. Key is that the output in the .pdf is controlled by two aspects: (A) the luacode, which produces the number at the end of the line, which is the exam Question points (the original luacode would produce a "total," so this is simulated for demonstration purposes) and (B) the absence of the "mode" variable. The "mode" conditional determines whether to print the solution as well, or just the exam question. Since the luacode part turns out to be of lesser importance, here, after all, nothing further about that is implemented. Those interested in the "mode" aspect can probably see where/how to add a suitable variable in order to activate the #3 from the input line (which input line consists of #1, an exam Question point value, #2, the exam Question, and #3, a Solution to the Question).

Here, then, is an MWE responsive to the original question as supplemented with the OP's MWE. The key lines of the original are commented out to show the conceptual differences, which turn out to be an in-context implementation of Wolfgang Schuster's accepted Answer (i.e., here using the OP's original parameter names and macros, to the extent possible).

\startluacode
userdata = userdata or {}

function userdata.getQval(weight, question)
local tot=tonumber(weight)
context("(" .. weight .. " points) " .. question .. " " .. tot)
end
\stopluacode

\def\getQuestionVal#1#2{%
\ctxlua{userdata.getQval([==[#1]==], [==[#2]==])}%
}

\definestructureconversionset[questionConversion][n,a,r][n]
\defineseparatorset[none][][]

\defineenumeration[questionEnumeration]
[
text={},
title=yes,
titlestyle=bold,
titleright={},
titleleft={},
indenting=always,
indentnext=yes,
aligntitle=yes,
stopper={)},
numberseparatorset=none,
numberconversionset=questionConversion,
]

\setupenumeration
[questionEnumeration]
[numberconversionset=questionConversion,
numbersegments=1,
%   numberstopper=),
alternative=serried,

\setupenumeration
[subquestionEnumeration]
[numbersegments=2,
margin=2em]

\setupenumeration
[subsubquestionEnumeration]
[numbersegments=3,
margin=4em]

\def\theQ#1#2#3{%
%\startquestionEnumeration[title=\getQuestionVal{#1}{#2}]
\getQuestionVal{#1}{#2}
\doifmodeelse{key}{\startcolor[red]#3\stopcolor}{\blank[#1*2em]}
%\stopquestionEnumeration
}

\def\theSubQ#1#2#3{%
%\startsubquestionEnumeration[title=\getQuestionVal{#1}{#2}]
\getQuestionVal{#1}{#2}
\doifmodeelse{key}{\startcolor[red]#3\stopcolor}{\blank[#1*2em]}
%\stopsubquestionEnumeration
}

\def\theSubSubQ#1#2#3{%
%\startsubsubquestionEnumeration[title=\getQuestionVal{#1}{#2}]
\getQuestionVal{#1}{#2}
\doifmodeelse{key}{\startcolor[red]#3\stopcolor}{\blank[#1*2em]}
%\stopsubsubquestionEnumeration
}

\starttext
%\enablemode[key]

\startquestionEnumeration
%       \questionEnumerate{3}{This is the question}{this is its sol}
\theQ{3}{This is the question}{this is its sol}
\stopquestionEnumeration

\startsubquestionEnumeration
%           \questionEnumerate{1}{This is sub question a}{this is a sol}
\theSubQ{1}{This is sub question a}{this is a sol}
\stopsubquestionEnumeration

\startsubquestionEnumeration
%           \questionEnumerate{1}{This is sub question b}{this is a sol}
\theSubQ{1}{This is sub question b}{this is a sol}
\stopsubquestionEnumeration

\startsubsubquestionEnumeration
%           \questionEnumerate{1}{This is sub sub question i}{this is a sol}
\theSubSubQ{1}{This is sub sub question i}{this is a sol}
\stopsubsubquestionEnumeration

\startsubsubquestionEnumeration
%           \questionEnumerate{1}{This is sub sub question ii}{this is a sol}
\theSubSubQ{1}{This is sub sub question ii}{this is a sol}
\stopsubsubquestionEnumeration

\startsubquestionEnumeration
%           \questionEnumerate{1}{This is sub question c}{this is a sol}
\theSubQ{1}{This is sub question c}{this is a sol}
\stopsubquestionEnumeration

\startquestionEnumeration
%       \questionEnumerate{3}{This is the question}{this is its sol}
\theQ{3}{This is the question}{this is its sol}
\stopquestionEnumeration

\stoptext


Which produces this: