2

I'd like to use a parallel and independent section numbering system for questions in exercises. What I want to achieve is similar to what is proposed in this page of the wiki ; however, I want many layers of questions (at least 3 or 4) while keeping many layers for my section numbering (until subsubsection at least), so I can't use this trick as is.

I also tried something inspired by the section 11.5 of the manual by defining

\definehead[one][section=questions-1]
\definehead[two][section=questions-2]

and so on, but I got an error saying the questions token was not initialized (if I understood well).

Does someone see a correct way to achieve this?

Bonus: would it be possible to define a command to easily skip a number (something like \skipquestion[one])?

EDIT

Following a remark by Adytia in the comments, I'll explain why I don't consider using enumerations : I want to be flexible for both small exercises and big exams. Here is my first attempt (limited to two levels, but it should go on), which worked as I wish except that it shares the counter with standard sectionning ; it is inspired by a previous document, so the main ideas aren't from me.

\def\NumberOne#1{\hbox to 4mm{#1.\ \hfil}}
\def\NumberTwo#1{\hbox to 8mm{#1\ --\hfil}}

\definehead[One][section]
\definehead[OneTitle][section]
\definehead[Two][subsection]
\setuphead[One][
    numbercommand=\NumberOne,
    distance=0mm,
    style=\bf,
    aligntitle=float,
    before=\noindenting,
    after=]
\setuphead[OneTitle][
     numbercommand=\NumberOne,
     conversion=Romannumerals,
     style={\rm\bfb},
     before={\blank[line]\noindenting},
     aligntitle=float,
     after=]
\setuphead[Two][
     numbercommand=\NumberTwo,
     conversion=numbers,
     alternative=text,
     distance=0mm,
     style=\bi,
     aligntitle=float,
     before=\noindenting,
     after=]

\def\T#1{\dodoubleempty\doHead[#1]}
\def\doHead[#1][#2]#3{%
    \ifcase#1 %T0
    \or %T1
      \doifemptyelse{#3}{\def\CurHead{\One}}{\def\CurHead{\OneTitle}}
    \or %T2
      \doifemptyelse{#3}{\def\CurHead{\Two}}{\def\CurHead{\TwoTitle}}
    \fi
  \CurHead[#2]{#3}
}

\T1{One title}  % prints I. One title
\T2 This prints 1.1
\T2 This prints 1.2
\T1 This prints 2

EDIT 2

Since enumerations were suggested, I tried this :

\defineenumeration[question][headstyle=bold,style=normal,
  indenting=never, indentnext=no, margin=-0.5mm,
  alternative=hanging, distance=0pt,
  width=4mm, stopper={.}, text={},
  before={\blank[none]},

]
\setupenumeration[subquestion][headstyle=bold,style=normal,
  indenting=never, indentnext=no, margin=-0.5mm,
  alternative=hanging, distance=0pt,
  width=6mm, stopper={.}, text={},
  before={\blank[none]},
]
\setupenumeration[subsubquestion][headstyle=sl,style=normal,
  indenting=never, indentnext=no, margin=-0.5mm,
  alternative=hanging, distance=0pt,
  width=8mm, stopper={.}, text={},
  before={\blank[none]},
]
\setupenumeration[subsubsubquestion][headstyle=sl,style=normal,
  indenting=never, indentnext=no, margin=-0.5mm,
  alternative=hanging, distance=0pt,
  width=10mm, stopper={.}, text={},
  before={\blank[none]},
]

\def\doTA[#1]{
  \doifsomethingelse{#1}
    {
      \nextquestion
      \blank[big]\noindenting
      {\rm\bfb\convertedcounter[question][numberconversion=R]. #1}
      \blank[small,samepage]
    }
    {
      \question
    }
}

\def\doTB[#1]{
  \doifsomethingelse{#1}
    {
      \nextsubquestion
      \blank[small]\noindenting
      {\hskip 1cm {\rm\bfa\convertedcounter[question][numberconversion=CCS]. #1}}
      \blank[small,samepage]
    }
    {
      \subquestion
    }
}

\def\doTC[#1]{
  \doifsomethingelse{#1}
    {
      \nextsubsubquestion
      \blank[big]\noindenting
      {\hskip 1cm \sl\convertedcounter[question][numberconversion=n]) #1}
      \blank[small,samepage]
    }
    {
      \subsubquestion
    }
}

\def\doTD[#1]{
  \doifsomethingelse{#1}
    {
      \nextsubsubquestion
      \blank[big]\noindenting
      {\hskip 1cm \sl\convertedcounter[question][numberconversion=n]. #1}
      \blank[small,samepage]
    }
    {
      \subsubsubquestion
    }
}

\def\TA{\dosingleempty\doTA}
\def\TB{\dosingleempty\doTB}
\def\TC{\dosingleempty\doTC}
\def\TD{\dosingleempty\doTD}

\starttext

\section{Bonjour}
\subsection{Rebonjour}
Hello
\subsubsection{Tagada}
y a
\subsubsection{Tsoin tsoin}
quelqu'un
\subsection{Le petit\dots}

\section{Lapin ! \name{Jazz}}


\TA[Big question]

\TB 
blabla
\TB
blabla

\TB[Subquestion]

\TC
Blabla
\TC
Blabla

\TC[Subsubquestion With title]

Blabla
\TD
Hello
\TD
Pouet

\TC
HEllo

\TA
Another question
\TA
Another question


\stoptext

It has quite a correct behavior, but I ask myself how I could finely tune the alignment of questions, and how I could define a conversion set to show, e.g, 1.2.a) for a subsubquestion. Thank you in advance.

  • Well in this post the sectionA and sectionB are independant ; I would like questions, subquestions and so on, in order to have the complete numbering (for instance, \two{} may print something like 2.3) – A. Licari Jul 14 '17 at 9:08
  • I see. Voting to reopen. – Henri Menke Jul 14 '17 at 12:12
  • Do the questions really have to numbered as section? Have you considered using Enumerations – Aditya Jul 14 '17 at 12:23
  • I need to have something really flexible : I may give a title to a question that embbeds many subquestions, and I'd like a different formatting in this case. I'm going to edit the question to show it. – A. Licari Jul 14 '17 at 12:55
  • To me it looks like you have (partially) answered the question yourself in your other question. Self-answers are totally legitimate on this site, so why not post your solution below? – Henri Menke Jul 16 '17 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.