Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a template document in Word 2010 that will serve as a Chapter (outline level 1, heading 1 format) in a larger Volume. In the Chapter, I need to have multiple Sections (outline level 2, heading 2 format). I want to use field codes to get the section number without the chapter number for use throughout the Section.

For example:

Chapter 20 - Chapter Title
20.1 Section One Title
20.1.1 Section One Subsection
  Something here needs a label that reads only '1', in reference to the 20.1 2nd number.
20.2 Section Two Title
  Something here needs a label that reads only '2', in reference to the 20.2 2nd number.

I am able to get "20.1" and "20.2" via STYLREF like { STYLEREF 2 \s }.

How can I get just "1" and "2"?

share|improve this question
up vote 0 down vote accepted

I can't help feeling that there must be an easier way, but if your numbers only range from 1 to 9 (e.g. 14.1-14.9, 20.1-20.9 etc., you could try the following nested fields (All the {} need to be the special "field code brace" characters you can enter with ctrl-F9, not the ordinary ones you type on the keyboard).

{ =10*{ STYLEREF 2 \s #.x } }

If you need 2 digits, things get more complicated, e.g.

{ ={ QUOTE "{ STYLEREF 2 \s }1" }*{ IF "{ QUOTE "{ STYLEREF 2 \s }1" }" = ".???" 100 10 } #0 }

share|improve this answer
It seems like it should be easier, but this is as ugly as I feared it would be. I did have to add a \ to all of the #s in the field codes to solve some syntax errors (changed to \#), but it works! Thanks. – Sam Jun 6 '13 at 15:57
Yes, sorry about the backslashes-keep forgetting they need special treatment here – bibadia Jun 6 '13 at 16:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .