[Tugindia] How to create Subchapters

bhutex bhutex at gmail.com
Mon Jul 27 15:17:31 CEST 2015


Hello all

One of our students is in the final stages of submitting his thesis. He
wants subchapters. We used the following hack for creating the subchapters:

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
%\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\newcounter{subchapter}\renewcommand{\thesubchapter}{\Alph{subchapter}}
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\newcommand{\updatechaptercounter}{}
\patchcmd{\@chapter}{\@afterheading}{\updatechaptercounter\@afterheading}{}{}%
Regular patch of \@chapter
%\patchcmd{\Hy at org@chapter}{\@afterheading}{\updatechaptercounter\@afterheading}{}{}%
Hyperref patch of \@chapter
\makeatother
\providecommand{\theHchapter}{}%
\newcommand{\startsubchapters}{%
  \setcounter{subchapter}{0}% Reset sub-chapter numbering
  \renewcommand{\thechapter}{\arabic{chapter}\thesubchapter}% Update
chapter number display
  \renewcommand{\theHchapter}{\arabic{chapter}\thesubchapter}% Update
chapter number display (for hyperref)
  \renewcommand{\updatechaptercounter}{\addtocounter{chapter}{-1}}% Update
chapter number
  \let\oldchapter\chapter%
  \renewcommand{\chapter}{\stepcounter{subchapter}\oldchapter}% Increment
subchapter
}
\newcommand{\stopsubchapters}{%
  \renewcommand{\thechapter}{\arabic{chapter}}% Reset chapter numbering
  \renewcommand{\theHchapter}{\arabic{chapter}}% Reset chapter numbering
(for hyperref)
  \let\chapter\oldchapter% Restore regular \chapter command
  \renewcommand{\updatechaptercounter}{}% Clear chapter counter update
  \stepcounter{chapter}% Update chapter counter
}


But is is not working in his thesis. The chapter number it is showing as 3a
and then 4b - not as 3a and 3b. He is using the Thesis class.

In the stand alone model also it is creating some trouble :

The subchapter number it is giving correctly like 3a, 3b, 3c etc. but the
section numbering is coming as 2a.1., 2a.2 or 2b.1, 2b.2 etc.

Tried to use TitelSec package. But it is hard to crack.

Googling on "Subchapters in LaTeX" is not giving any clue.

Any help will be highly appreciated.


-- 
D. Venu Gopal
Member - TeX User Group
The BHU TeX Group


More information about the tugindia mailing list