TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. 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

In a certain section of my document, I want to reference the number of subsections in this section ("In the following X subsections ..."). Is there any way to do this programmatically?

share|improve this question
it can almost certainly be done with the use of an .aux file and multiple passes. – barbara beeton Aug 2 '12 at 12:34

Here's a \howmany command that takes as argument a label for referring to the number of times the counter given as optional argument (default subsection) has been stepped since last time it's been reset.



This document has \ref{sections} sections.
In the following \ref{subsecA} subsections we'll talk about many things.





share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.