Suppose I am creating, say, 50 individual LaTeX files (one for each lecture).

I wish to label all my theorems/propositions in the first file as 1.1, 1.2, etc. but then in the second file I want them all labelled as 2.1, 2.2, etc., up until the 50th lecture, where everything would be labelled as 50.1, 50.2 etc.

In other words, each individual LaTeX file has everything numbers consecutively, but (apart from the first file), the numbering won't start at 1. What is the easiest way to accomplish this?

Second question: at the end of the semester I will glue the 50 files together (so the students get one combined file). Ideally the solution to the previous question will involve minimal fuss when the files are pasted together.

  • 1
    You can define each lecture file as a \chapter which are \include-d into the general one. And compile this one with \includeonly option for each individual chapter. This way, each lecture will keep its own number.
    – Ignasi
    Commented Jan 12, 2017 at 16:40

1 Answer 1


It depends on how you define your "lecture" environment. However, the following would suffice and allow you to merge them together at the end:




  \def\theHtheorem{#1.\arabic{theorem}}% ...if you're loading hyperref









\settheoremprefix{<stuff>} prepends <stuff>. to every theorem number. If you're loading hyperref, care is taken to ensure correct hyperlink jumps will result by also updating \theHtheorem - a hyperref-specific counter.

A more generic version \setcounterprefix{<counter>}{<stuff>} can also be used

  \expandafter\def\csname theH#1\endcsname{#2.\arabic{#1}}% ...if you're loading hyperref
  \expandafter\def\csname the#1\endcsname{#2.\arabic{#1}}%

For example,

  • Thank you very much for your answer, this worked perfectly. How would I achieve the same thing with labelling equations?
    – Doc
    Commented Jan 14, 2017 at 13:45

You must log in to answer this question.

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