Difference between revisions of "Last Head Number"

From Wiki
Jump to navigation Jump to search
Line 5: Line 5:
 
<texcode>
 
<texcode>
 
\dorecurse {5} {
 
\dorecurse {5} {
   \chapter{Test #1}
+
   \chapter{Test \recurselevel}
 
   first:  \somestructureheadnumber[chapter][first]  \par
 
   first:  \somestructureheadnumber[chapter][first]  \par
 
   current: \somestructureheadnumber[chapter][current] \par
 
   current: \somestructureheadnumber[chapter][current] \par
 
   last:    \somestructureheadnumber[chapter][last]
 
   last:    \somestructureheadnumber[chapter][last]
 
   \dorecurse {3} {
 
   \dorecurse {3} {
     \section{Test #1}
+
     \section{Test \recurselevel}
 
     first:  \somestructureheadnumber[section][first]  \par
 
     first:  \somestructureheadnumber[section][first]  \par
 
     current: \somestructureheadnumber[section][current] \par
 
     current: \somestructureheadnumber[section][current] \par

Revision as of 11:35, 12 August 2010

To access the last head number in a document one can use:

\somestructureheadnumber[][]

The following example from the mailing list demonstrates how to use it.

\dorecurse {5} {
  \chapter{Test \recurselevel}
  first:   \somestructureheadnumber[chapter][first]   \par
  current: \somestructureheadnumber[chapter][current] \par
  last:    \somestructureheadnumber[chapter][last]
  \dorecurse {3} {
    \section{Test \recurselevel}
    first:   \somestructureheadnumber[section][first]   \par
    current: \somestructureheadnumber[section][current] \par
    last:    \somestructureheadnumber[section][last]
  }
}

For using inside a Metapost-environment you can use the expandable version:

\somenamedheadnumber{}{}