I am writing lecture notes referring to specific chapters and sections in the textbook chapters and sections.

I use multiple textbooks, so Chapters 1 and 2 of my lecture notes may be from Textbook X, but Chapter 3 of the lecture notes is Chapter 5 in Textbook Y. Similarly for sections. I simply want the section numbering in my lectures to reflect the true section numbers of the respective parts in the textbooks. I put a note at the beginning of every chapter/section to identify the current textbook.

So my question is: how can I re-number specific chapters/sections in a report personally?

  • 1
    What \documentclass are you using? Also, are you using hyperref?
    – Werner
    Jun 1 '13 at 1:21
  • \documentclass{report} and I might want to use hyperref later. thanks
    – Aya
    Jun 1 '13 at 1:44

Here's a complete implementation that allows you to specify the \chapter and section numbering at your own discretion. It works with/without hyperref:

enter image description here

enter image description here

enter image description here

\usepackage{regexpatch}% http://ctan.org/pkg/regexpatch

\xpatchcmd*{\@sect}{the#1}{fixed@seccntformat}{}{}% Insert fixed reference in ToC
\xpatchcmd*{\@sect}{\relax\@svsec}{\relax\fixed@seccntformat\quad}{}{}% Insert fixed reference in heading
\xpatchcmd{\l@chapter}{1.5em}{3.5em}{}{}% Lengthen space for ToC number entry
  \renewcommand{\chapter}[1]{\xdef\thechapter{##1}% Store chapter #
    \old@chapter}% Old chapter
\renewcommand{\section}[1]{\xdef\fixed@seccntformat{#1}% Store section #
  \old@section}% Old section
\renewcommand{\subsection}[1]{\xdef\fixed@seccntformat{#1}% Store subsection #
  \old@subsection}% Old subsection

\usepackage{hyperref}% http://ctan.org/pkg/hyperref




\chapter{A.1.B}[Here's a chapter]{A chapter}
\section{3.4}{A section}
\section{1.2}{Another section}
\chapter{1718}{Another chapter}
\section{5}{Yet another section}
\section{8.8}*{Also a section}


The idea is different for \chapter, but similar for all sectioning commands. For sections, the number is stored in \fixed@seccntformat and patched in the section setting macro \@sect. For \chapters, the counter printing macro \thechapter is updated with the required number.

The reason for supplying \fixchapters is that elements of the \frontmatter use the starred variant of \chapter which are embedded inside macros like \tableofcontents and the \listof-clan. Of course, a better interface can be adopted, if needed.

Some considerations:

  • The interface requires you to supply a mandatory argument as the first argument to all sectioning macros. So you will use \section{<number>}[<ToC>]{<title>} always. Similar for \chapter{<number>}[<ToC>]{<title>}.

  • Depending on the chapter/section number length, you might have to update the \l@chapter and/or \l@<section> macros to give you more space in the ToC. You'll notice, in my example above, that I've increased the regular 1.5em chapter \numberline width to 3.5em.

  • This looks exactly like what I want, although I am not able to compile it yet because of the package you are using. I need to download the file and try then will come back. Thanks very much.
    – Aya
    Jun 3 '13 at 3:49

I'm a bit foggy about the implementation you're looking for. Here's an idea, but I might be missing the point:


\tl_new:N \l_my_lecture_book_title_tl
\tl_new:N \l_my_lecture_author_tl
\keys_define:nn{ my_lectures }
        chapter . code:n = { \setcounter{chapter}{\number\numexpr#1\relax}},
        section . code:n = { \setcounter{section}{\number\numexpr#1-1\relax}},
        book    . tl_set:N = \l_my_lecture_book_title_tl,
        author  . tl_set:N = \l_my_lecture_author_tl
\NewDocumentCommand{\mylecture}{ om }
        \keys_set:nn { my_lectures } { #1 }
                 {\small \tl_use:N \l_my_lecture_book_title_tl
                (\tl_use:N \l_my_lecture_author_tl)}}



\chapter{Modeling Random Times}
           book={Stochastic Differential Equations},
           author={Bernt \O{}ksendal},
          ]{What's a Random Time Change}


           author={Freedman, Pisani, Purves}
          ]{Modeling Random Events}




enter image description here

There are several issues, some of which might be:

  • A table of index will have slightly confusing numbering going on. But you might not care about this. If you do, please elaborate how you want that handled.

  • The \section command is called with an optional argument solely because I thought you might want a table of contents.

  • The is a very neat approach.
    – Werner
    Jun 1 '13 at 3:35
  • This is very neat and may benefit me well later. But I would also need to rename chapters randomly, not just sections. Thank you very much.
    – Aya
    Jun 3 '13 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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