mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] Continue enumeration


Chronological Thread 
  • From: Enrique Perez-Terron <address@hidden>
  • To: address@hidden
  • Subject: Re: [TeXmacs] Continue enumeration
  • Date: Sat, 11 Oct 2008 05:25:54 +0200

On Wed, 2008-10-08 at 13:53 +0200, Benno Dielmann wrote:
> Well, there is one (though suboptimal): You can assign the item-nr variable
> at
> the start of the second list. Do do this, move the cursor to the start of
> the
> second list to the left of the numbering but still in the list environment
> (blue frame). Then put an assign statement there (e.g. by entering \assign)
> and enter "item-nr" (without the "") into the first field and the number of
> the
> last item of the second list into the second field. In your example, this
> would
> be "2" (without "").
>
> The bad thing is, if you expand the first list by adding more items, you
> always
> have to adapt the value you assign to item-nr. I tried to put a label in
> the
> first list and a reference to it in the assign field, but Texmacs doesn't
> eat
> it, probably because it's a string and not a number. I didn't find a way to
> convert strings to numbers, either.


In a package file:

<assign|list-save-state|\
<macro|label|\
<quasi|\
<assign|<unquote|<arg|label>>|\
<value|item-nr>\
>>>>
<assign|list-restore-state|\
<macro|label|\
<assign|item-nr|\
<value|<arg|label>>\
>>>

In a document using the package:

<\enumrate-numeric>
<item>This is the text of the first item.

<item>This is the text of the second item.

<item>This is the text of the third item.<list-save-state|potato>
</enumerate-numeric>

Some unstructured remarks.

<\enumerate-numeric><list-restore-state|potato>
<item>This is the text of the fourth item.

<item>This is the text of the fifth item.
</enumerate-numeric>

Here I have used the label "potato" to save and restore the state. A
potential problem is that some other package or even texmacs itself
could be using the word "potato" to name some some environment variable.
To minimize the risk of name collisions, the macros could have

<merge|list-saved-state-|<arg|label>>

instead of just <arg|label>, whereever that occurs. That would make the
label be "list-saved-state-potato" internally.

What still remains a disadvantage with all this is that unless one
switches to source view, the macro calls are hidden, and there is
nothing in the user interface that interacts with the macros. If you
forget the label you used, or forget that you put in the
list-restore-state, and later return to the document, you will be
mystified.

I just tried. It worked. Here is the contents of
.TeXmacs/packages/save-state.ts:

<TeXmacs|1.0.6.15>

<style|source>

<\body>

<assign|list-save-state|<macro|mylabel|<quasi|<assign|<unquote|<merge|list-saved-|<arg|mylabel>>>|>>>>


<assign|list-restore-state|<macro|mylabel|<assign|item-nr|<value|<merge|list-saved-|<arg|mylabel>>>>>>
</body>

To use it, in the second list environment, I inserted the environment
using the gui interface, then I pressed left arrow and checked that the
status bar said "before item", then I hit \, typed list-restore-state,
Enter, potato, enter.

Regards
Enrique




Archive powered by MHonArc 2.6.19.

Top of page