[Tugindia] How to create Subchapters
Harish Kumar Holla
harishkumarholla at pec.edu
Mon Jul 27 15:47:02 CEST 2015
Here is some starter.
\documentclass{book}
\usepackage{titlesec}
\titleclass{\subchapter}{straight}[\chapter]
\newcounter{subchapter}
\renewcommand{\thesubchapter}{\Alph{subchapter}}
\newcommand{\subchaptertitlename}{Sub chapter}
\titleformat{\subchapter}[display] %% adjust whether this should be
display or not
{\normalfont\LARGE\bfseries}{\subchaptertitlename\
\thechapter.\thesubchapter}{15pt}{\huge}
\titlespacing*{\subchapter} {0pt}{50pt}{40pt} %% adjust this spacing
\begin{document}
\chapter{Introduction}
Some introductory text here.
\subchapter{Some subchapter}
Text here
\section{Section here}
\subchapter{Some subchapter}
Text here
\section{Section here}
\subchapter{Some subchapter}
Text here
\section{Section here}
\chapter{First chapter}
Some introductory text here.
\subchapter{Some subchapter}
Text here
\section{Section here}
\subchapter{Some subchapter}
Text here
\section{Section here}
\subchapter{Some subchapter}
Text here
\section{Section here}
\end{document}
On Mon, Jul 27, 2015 at 7:05 PM, Harish Kumar Holla <
harishkumarholla at pec.edu> wrote:
> I think you need to read section 3.9 of the titlesec manual.
>
> Something like
>
> \titleclass{\subchapter}{straight}[\chapter]
> \newcounter{subchapter}
> \renewcommand{\thesubchapter}{\Alph{subchapter}}
>
> should work. straight will create titles in the middle of text (like
> sections). If you want subchapters like chapters (i.e., at the top of the
> page) use top instead of straight. Hope that helps.
>
> As usual, if you provide a complete (compilable) MWE, I can provide tested
> results :-)
>
> On Mon, Jul 27, 2015 at 6:47 PM, bhutex <bhutex at gmail.com> wrote:
>
>> 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
>> _______________________________________________
>> Home: http://www.tug.org.in/
>> TeX FAQ: http://www.tex.ac.uk/faq
>> unsubscribe: http://tug.org/mailman/listinfo/tugindia
>>
>
>
>
> --
> with regards
> =========================
> Dr. Harish Kumar
> Dept. of Physics
> Pondicherry Engineering College
> Puducherry 605 014
> Ph: 0413 2655281-286 (Extn: 646)
> ---------------------------------------------
> Residence:
> Dr. Harish Kumar
> # 29 (New No.) I Main Cluny Road
> Avvai Nagar, Lawspet
> Puducherry 605 008
> Ph: 0413 2253652, 9443052957
> =========================
>
--
with regards
=========================
Dr. Harish Kumar
Dept. of Physics
Pondicherry Engineering College
Puducherry 605 014
Ph: 0413 2655281-286 (Extn: 646)
---------------------------------------------
Residence:
Dr. Harish Kumar
# 29 (New No.) I Main Cluny Road
Avvai Nagar, Lawspet
Puducherry 605 008
Ph: 0413 2253652, 9443052957
=========================
More information about the tugindia
mailing list