TransWikia.com

How to swap section labels and section numbers in ConTeXt

TeX - LaTeX Asked by user193767 on December 6, 2020

Is there a way to achieve the following in ConTeXt?

1. Part. A part
   1. Chapter. A chapter
      1.1 Section. A section
etc.

I’ve tried manually putting currentstructurelabel inside a command so it passes to command=... in setuphead, but it does not work.

EDIT

My approach

mainlanguage[es]
define[2]MyChapter
{framed[frame=off,width=broad,align=middle]{{tfx #1{ currentstructurelabel}}blank[medium]{cap{#2}}}}
setuphead[chapter][alternative=middle,command=MyChapter]
starttext
startchapter[title=lol]
Hola
stopchapter 
stoptext 

It prints 1 chapter (blank) lol instead of 1 capítulo... or 1 Capítulo.... If my mother tongue were English, I wouldn’t mind, but I use language switches and I wonder why is the label in English despite of language settings. So, how to make my attempt language-dependent?

One Answer

ConTeXt has a prebuild mechanism to add text to a section counter.

To add a text in front of the chapter counter you have to set a labeltext with the name of the section as key.

setuplabeltext [en] [chapter=Chapter ]

starttext

chapter{A chapter}

stoptext

In the example above the text appeared before the counter but it's also possible to put a text after it, to do this you have to use a list where the text has to be the second entry in the list.

setuplabeltext [en] [chapter={, chapter}]

starttext

chapter{A chapter}

stoptext

Answered by Wolfgang Schuster on December 6, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP