How can I have a custom numbered field?

In Writer, I would like a custom field, incrementing throughout the document, attached to my own counter. The end result should be somewhat like page number, but it displays instead its position within the document (so the Nth instance of this field says “N”).

The use case is numbering problems in an exam - I would like to be able to insert an automatic field in problem headings, so that the problem is labeled “Problem N”, with N auto-updating if I move problems around in the exam.

Is there a way to do this?

You can do this by defining your own field of type “Number Range”. Assuming you already have at least one heading that should contain the custom numbering, do the following:

  • Put the cursor to where the field should be inserted;

  • Open Menu “Insert” → “Fields” → “Other...” or hit “CTRL+F2”; the “Insert Fields” dialogue will appear.

  • Select tab “Variables”:

  • in the left list box ("Type"), select “Number Range”;

  • don’t select an entry from “Selection”;

  • enter a name at “Name” to create a new number range;

  • leave “Value” empty;

  • select “Format” as desired:

  • Hit “Insert” to insert a field for the new number range.

For further usage, the custom number range will be available in the “Insert Fields” dialogue, tab “Variables”, list box “Selection”. Just insert fields using that number range as desired. The fields will get updated if you move the headings around.

Perfect, thanks!

I don’t know a direct way, but perhaps this workaround is useful or at least usable for you:

Open Format->Styles and formatting
rightclickand choose ‘new’ from Contextmenu
Create a new Format for your ‘Problem Headline’ and adjust all your formating preferences you need. If there is already a style you use you may also use the button in the right top to create a ‘New Style from selection’ and after creating rightclick and choose modify.

Now switch to tab ‘Outline and numbering’ and choose Numbering 1.

Now slect all your ‘Problem Headers’ and they will be numbered automatically in the order they appear in the document. When you are ready with your exam you may manually insert the problem Number taking the number from the headline.

If you already use numbering for your chapters, then disable numbering temporarily in the headline-style.

Hope that helps

Stefan