rgheck <rgh...@bobjweil.com> writes:
> The point of this patch is that sometimes one wants enumerations that
> behave differently, even within a single document. E.g, I've got an
> Enumerati environment that gives me enumerations with \roman, \Roman,
> \alph, \Alph, and I'd like to see them that way. Your solution changes
> everything globally.

What I would do is work in a more latex-ish way: define a new set of
counters "myenumi"..."myenumiv" with the corresponding labelstring and
set Enumerati to use "myenum" as counter (which means that we will have
to read the layout counter for enumrations).

Starting from the patch below, it is easy to define the enumeration that
you describe here. It might end up a bit longer than what you describe
here, but at least we do not have to add ad-hoc layout syntax.

This patch can probably go to 1.6.4 actually (up to Juergen).

One remaining bug is that theCounter does not translate its string, it
would need for that to get an extra BufferParams argument.

JMarc

svndiff

Index: src/Counters.cpp
===================================================================
--- src/Counters.cpp	(révision 29902)
+++ src/Counters.cpp	(copie de travail)
@@ -435,6 +435,7 @@ docstring Counters::theCounter(docstring
 	CounterList::const_iterator it = counterList_.find(counter); 
 	if (it == counterList_.end())
 		return from_ascii("??");
+	// FIXME: this should get translated.
 	return counterLabel(it->second.flatLabelString(appendix()));
 }
 
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(révision 29902)
+++ src/Buffer.cpp	(copie de travail)
@@ -3191,9 +3191,7 @@ static void setLabel(Buffer const & buf,
 	}
 
 	case LABEL_ENUMERATE: {
-		// FIXME: Yes I know this is a really, really! bad solution
-		// (Lgb)
-		docstring enumcounter = from_ascii("enum");
+		docstring enumcounter = layout.counter.empty() ? from_ascii("enum") : layout.counter;
 
 		switch (par.itemdepth) {
 		case 2:
@@ -3214,31 +3212,9 @@ static void setLabel(Buffer const & buf,
 		// Maybe we have to reset the enumeration counter.
 		if (needEnumCounterReset(it))
 			counters.reset(enumcounter);
-
 		counters.step(enumcounter);
 
-		string format;
-
-		switch (par.itemdepth) {
-		case 0:
-			format = N_("\\arabic{enumi}.");
-			break;
-		case 1:
-			format = N_("(\\alph{enumii})");
-			break;
-		case 2:
-			format = N_("\\roman{enumiii}.");
-			break;
-		case 3:
-			format = N_("\\Alph{enumiv}.");
-			break;
-		default:
-			// not a valid enumdepth...
-			break;
-		}
-
-		par.params().labelString(counters.counterLabel(
-			par.translateIfPossible(from_ascii(format), bp)));
+		par.params().labelString(counters.theCounter(enumcounter));
 
 		break;
 	}
Index: lib/layouts/stdcounters.inc
===================================================================
--- lib/layouts/stdcounters.inc	(révision 29902)
+++ lib/layouts/stdcounters.inc	(copie de travail)
@@ -33,18 +33,22 @@ Counter subparagraph
 End
 
 Counter enumi
+	LabelString          "\arabic{enumi}."
 End
 
 Counter enumii
 	Within               enumi
+	LabelString          "(\alph{enumii})"
 End
 
 Counter enumiii
 	Within               enumii
+	LabelString          "\roman{enumiii}."
 End
 
 Counter enumiv
 	Within               enumiii
+	LabelString          "\Alph{enumiv}."
 End
 
 Counter bibitem
Index: lib/layouts/stdlists.inc
===================================================================
--- lib/layouts/stdlists.inc	(révision 29902)
+++ lib/layouts/stdlists.inc	(copie de travail)
@@ -43,6 +43,7 @@ Style Enumerate
 	Align                 Block
 	AlignPossible         Block, Left
 	LabelType             Enumerate
+	LabelCounter          "enum"
 End
 
 

Reply via email to