在 ConTeXt 中使用时,是否有与的标志\setupenumeration
等效的标志?我希望我的自定义枚举子级别遵循以下模式\setupitemgroup
norepeat
1)
a)
b)
i)
ii)
c)
2)
但无法删除领先的父组数字,使得格式看起来像
1)
1.a)
1.b)
1.b.i)
1.b.ii)
1.c)
2)
我尝试使用继承的参数\setupcounter
,但到目前为止,它们都没有任何效果。
编辑:我在下面添加了我一直在使用的代码的简化形式。我希望使用 \defineenumeration 命令而不是 itemize 命令。不过我可能对它们的应用感到困惑?
\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
答案1
您可以使用键控制每个枚举级别显示的数字numbersegments
。
\defineconversionset [question] [n,a,r] [n]
\defineenumeration [question] [text=]
\setupenumeration
[question]
[numberconversionset=question,
numberstopper=),
alternative=serried,
width=broad]
\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
答案2
我预计您正在寻找的帮助页面是这里。
这是一个非常简短的 MWE,它重现了您要询问的内容:
\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
结果是这样的:
答案3
网站对我添加另一个答案的门槛问题是是否添加一个答案或编辑原始答案。由于 ConTeXt 中的基本枚举相关但又不同,我希望通过保留原始答案,有类似问题的人可以更清楚地了解差异。
主要思想归结为这一点。编号具有自动格式化功能,它包括所有前面的级别,因此,1、1.a、1.ai 等。为了避免整个编号格式,必须自定义每个级别的编号,这是 Wolfgang Schuster 的观点。
对 ConTeXt 枚举很有帮助的是 Hans Hagel 的ConTeXt--手册 § 10.3(第 228-30 页)
在下面提供的内容中,原始 MWE 的 luacode 段被修改(显著)。原始代码在 OP 的系统上是有意义的,但如果没有该数据库和上下文中的相关代码,则“没有”任何变量被定义,因此需要进行模拟。关键是 .pdf 中的输出由两个方面控制:(A)luacode,它在行尾产生数字,即考试问题点(原始 luacode 会产生“总数”,因此出于演示目的进行模拟)和(B)没有“模式”变量。“模式”条件确定是否也打印解决方案,或者仅打印考试问题。由于 luacode 部分的重要性较低,因此,这里毕竟没有进一步实现这一点。对“模式”方面感兴趣的人可能会看到在哪里/如何添加合适的变量以从输入行激活 #3(该输入行由 #1、考试问题点值、#2、考试问题和 #3、问题解决方案组成)。
那么,这里是响应原始问题的 MWE,并补充了 OP 的 MWE。原始的关键行被注释掉以显示概念上的差异,结果证明这是 Wolfgang Schuster 接受的答案的上下文实现(即,这里尽可能使用 OP 的原始参数名称和宏)。
\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,
width=broad]
\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
由此产生了如下结果: