2

I am trying to learn how to use enumerations. I tried to set a numbering set, following this page of the wiki, but it doesn't work. Is it possible to achieve without redefining all counters ?

\definestructureconversionset[myconversion][n, a, a, a][n]

\defineenumeration[test]

\setupenumeration[test]
                 [headstyle=bold,style=normal,
                   indenting=never, indentnext=no, margin=-0.5mm,
                   alternative=hanging, distance=0pt,
                   width=6mm, stopper={.}, text={},
                   before={\blank[none]},
                   prefixconversionset=myconversion]

\starttext

\test bla
\subtest ploup
\test bla

\stoptext

Thank you in advance.

EDIT

After Metafox's intervention, I had the correct behavior with the previous MWE, but not with my real environment. The sole definition of the complete enumeration is already not behaving correctly. Here is a more complete MWE :

\definestructureconversionset[myconversion][n,n,a,a][n]

\defineenumeration[question]

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

\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]. #1}}
      \blank[small,samepage]
    }
    {
      \subquestion
    }
}

\def\doTC[#1]{
  \doifsomethingelse{#1}
    {
      \nextsubsubquestion
      \blank[big]\noindenting
      {\hskip 1cm \sl\convertedcounter[question]) #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

\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

In this case the conversion does not work for subsubquestions and subsubsubquestions. Is there any option I used in these that interacts with the conversion ?

  • 1
    Replace the prefixconversionset key with numberconversionset. – Wolfgang Schuster Jul 15 '17 at 15:56
  • It works with the MWE but not with something more along the lines of my real usage. I edit my answer to explain. – A. Licari Jul 15 '17 at 16:30
  • 2
    You need a comma after numberconversionset=myconversion, otherwise the space (which is inserted by the line break) after the argument is taken as part of it. – Wolfgang Schuster Jul 15 '17 at 22:05
  • @Metafox This sounds like an answer. Please post it in the answer section below. – Henri Menke Jul 16 '17 at 2:45
  • It works indeed. How can I suggest to add it in the manual / the wiki ? – A. Licari Jul 16 '17 at 7:34
4

You have to end the last entry in your setups for the number conversion with a comma, because the line break is converted to a space and you pass myconversion  (with a space at the end of the name) to the numberconversionset key.

The correct way to write a setup is to end the last entry with a command

\setupenumeration
  [...]
  [
     numberconversionset=myconversion,
  ]

or put the right bracket after the last entry

\setupenumeration
  [...]
  [numberconversionset=myconversion]

In most cases there is no difference between both ways but when you use a older version of ConTeXt the first method doesn’t work for some commands (e.g. \definepalet).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.