0

I'm using the latex class report.

I can't find a way to put a single chapter title at both the center of the page and the top of the page. I tried using this method but I couldn't use the command \chapter*. Do you have any idea how I could do that?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 26 '21 at 16:13
  • I think you should do that with the titlesec package. It defines a titlespacing and a \titleformat commands. – Bernard Oct 26 '21 at 16:53

1 Answers1

1

If it is just one instance of a chapter, you could implement a solution ad hoc that does everything a normal \chapter does:

  • starts a new page at correct side: \cleardoublepage
  • increment chapter counter the proper way (works with \label): \refstepcounter{chapter}
  • add that chapter to Table of Contents: \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}<title of chapter here>}
  • set page marks: \chaptermark{<title of chapter here>}

After that, you can just make your title “by hand”. You could copy some of the style of chapter from report class: open report.cls (find its path on .log file) and search for definition of command \@makechapterhead.

I put everything together in the following MWE, making a definition in \customchapter.

\documentclass{report}
\usepackage{ifthen}

% a no numbered custom chapter \newcommand{\nonumberchapter}[2][]{% % handle optional short chapter title \ifthenelse{\equal{#1}{}}% {\def\customchapterShortTitle{#2}}% {\def\customchapterShortTitle{#1}}% % start a new page at correct side \cleardoublepage % providing an anchor for hyperref
\csname phantomsection\endcsname % add chapter to Table of Contents \addcontentsline{toc}{chapter}{\customchapterShortTitle}% % set page marks \chaptermark{\customchapterShortTitle}% % draw chapter title {\centering % \vspace{20pt} % space before Chapter N \Huge\bfseries #2\par\nobreak \vspace{40pt}}}

% a custom chapter \newcommand{\customchapter}[2][]{% % handle optional short chapter title \ifthenelse{\equal{#1}{}}% {\def\customchapterShortTitle{#2}}% {\def\customchapterShortTitle{#1}}% % start a new page at correct side \cleardoublepage % providing an anchor for hyperref
\csname phantomsection\endcsname % increment chapter counter the proper way \refstepcounter{chapter}% % add chapter to Table of Contents \addcontentsline{toc}{chapter}{% \protect\numberline{\thechapter}\customchapterShortTitle}% % set page marks \chaptermark{\customchapterShortTitle}% % draw chapter title {\centering % \vspace{20pt} % space before Chapter N \huge\bfseries Chapter \thechapter\par\nobreak \vspace{20pt}% \Huge #2\par\nobreak \vspace{40pt}}}

\begin{document}

\tableofcontents

\chapter{A normal chapter}

Some text.

\customchapter{A custom chapter}

Some text.

\nonumberchapter{A custom nonumber chapter}

Some text.

\end{document}

Edit: added after not numbered version too.

Edit2: added \phantomsection in order to work with hyperref.

  • Thank you really much, but I don't know how with that I could make a chapter without the chapter indication at each new chapter. Do you know how I could do that? (and sorry if it's not the good place to respond to your comment, that's the first I used this site to ask something) – Dante Mtlg Oct 26 '21 at 18:11
  • You could look at the definition of \chapter (and its subsidiary macros) in book.cls, but it is much more complicated. OTOH, you really only need to modify \@makechapterhead. – John Kormylo Oct 26 '21 at 21:31
  • @DanteMtlg, now I see that you do not want. I edited the MWE to add this case. – Miguel V. S. Frasson Oct 26 '21 at 22:18
  • @MiguelV.S.Frasson thank you very much! I just succeed to reduce the space between the chapter title and the top of the page with the command newgeometry but there is still something annoying, it doesn't seem to work with the hyperref package, the table of contents returns the page of the last chapter or section. Do you have any idea how it could be fixed? – Dante Mtlg Oct 27 '21 at 14:35
  • @DanteMtlg, in the definitions that I gave, add \phantomsection after \cleardoublepage. – Miguel V. S. Frasson Oct 28 '21 at 20:10
  • @MiguelV.S.Frasson nice thank you very much! It perfectly works! – Dante Mtlg Oct 29 '21 at 14:57