1

I am writing PhD Thesis on overleaf but the title of the chapter being vanished whenever I insert the package \usepackage[ruled]{algorithm2e} for the algorithm and the algorithm appears in good formate. Whenever I am removing the package \usepackage[ruled]{algorithm2e} the algorithm appears in bad formate and the title appears in good formate.

Anyone with this link can edit this project https://www.overleaf.com/9127796831jszrmzbxmfyn Anyone with this link can view this project https://www.overleaf.com/read/zswrfmqdbpft

you can access the overleaf file by above link. Please go to conclusion.tex to see the change in chapter 3 and go to the main.tex file for package change.

5
  • One problem with the template is the use of book.cls. It's been modified and doesn't work properly when generating \chapters.
    – Werner
    Jun 26, 2021 at 16:42
  • I shared the formate only, did not share my actual version of the thesis, so please inform me which file need to modified or delete? Jun 28, 2021 at 4:46
  • What you shared is a project that has a file called book.cls. Are you saying you don't have that as part of your version? It's difficult to help you without seeing exactly what you're seeing.
    – Werner
    Jun 28, 2021 at 16:00
  • sorry, I was busy with some other work, I am sharing that link where is the same error are present, you go through the following link: overleaf.com/5571471828tjhwmgqmzwqc Aug 25, 2021 at 10:33
  • the error: chapter heading is not in correct formate when involve the package \usepackage[ruled]{algorithm2e} Aug 25, 2021 at 10:35

1 Answer 1

0

The current problem with your setup is the redefinition of \@chapter inside the book.cls class. Typically \@chapter is defined to take two arguments - the first being optional and the second mandatory (taken from book.cls):

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}

Your class has been modified to make \@chapter take three arguments:

\def\@chapter[#1]#2#3{\ifnum \c@secnumdepth >\m@ne %%%Changed by Rajarshi
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#2}%
                       \else
                         \addcontentsline{toc}{chapter}{#2}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#2}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#1}]%
                    \else
                      \@makechapterhead{#3}%
                      \@afterheading
                    \fi}

Rajarshi must have had something in mind here... :)

algorithm2e taps into \@chapter to insert content into the List of Algorithms (LoA), but it doesn't keep the three-argument definition of \@chapter. Here's the definition inside algorithm2e.sty:

\def\@chapter[#1]#2{\algocf@original@chapter[#1]{#2}\addtocontents{loa}{\protect\addvspace{10\p@}}}% 

This has to change to

\def\@chapter[#1]#2#3{\algocf@original@chapter[#1]{#2}{#3}\addtocontents{loa}{\protect\addvspace{10\p@}}}% 

so that the third argument is captured properly.

There are more problems, but this at least solves the issue with \chapters.

1
  • thank you very much Aug 26, 2021 at 10:40

You must log in to answer this question.

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