0

I'd like to change chapter format, including lines up and down and text right aligned, like in the next figure, without using titlesec package:

enter image description here

Here it's my code:

\documentclass[a4paper,openright,12pt]{report}
\usepackage[utf8]{inputenc} 

\makeatletter
\def\@makechapterhead#1{%
\vspace*{0\p@}%
{\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
    \huge\bfseries
    % \@chapapp\space % removed
    \thechapter
    \nobreakspace{}% \par\nobreak\vskip 20\p@ % replaced
    \fi
    \interlinepenalty\@M
    \huge % \Huge % replaced
    \bfseries #1\par\nobreak
    \vskip 25\p@
}}
\makeatother

\begin{document}

\chapter{Chapter}

\end{document}

In the preamble, the code it's in order to change chapter format from "Chapter 1 \\ Chapter title" to "1. Chapter title".

Someone has any idea to include lines and align text to the right as shown in the above image? Thank you.

  • 1
    Why don't you want to use titlesec? – user156344 Apr 9 at 12:18
  • Because in my main document I have a lot of packages included, and when I load titlesecpackage, compilation fails. It seems like there are problems among packages. – Daniel Apr 9 at 12:22
1

With \hrule.

\documentclass[a4paper,openright,12pt]{report}
\usepackage[utf8]{inputenc}

\makeatletter
\def\@makechapterhead#1{%
\vspace*{0\p@}
\hrule\  \\
{\parindent \z@ \raggedleft \normalfont
    \ifnum \c@secnumdepth >\m@ne
    \huge\bfseries
    % \@chapapp\space % removed
    \thechapter
    \nobreakspace{}% \par\nobreak\vskip 20\p@ % replaced
    \fi
    \interlinepenalty\@M
    \huge % \Huge % replaced
    \bfseries #1\par\nobreak
    \vskip 10\p@
    \hrule
}}
\makeatother

\begin{document}

\chapter{Chapter}

\end{document}

enter image description here

With \rule.

\documentclass[a4paper,openright,12pt]{report}
\usepackage[utf8]{inputenc}

\makeatletter
\def\@makechapterhead#1{%
\vspace*{0\p@}
\noindent\rule{\textwidth}{2pt}\\
{\parindent \z@ \raggedleft \normalfont
    \ifnum \c@secnumdepth >\m@ne
    \huge
    % \@chapapp\space % removed
    \thechapter
    \nobreakspace{}% \par\nobreak\vskip 20\p@ % replaced
    \fi
    \interlinepenalty\@M
    \normalfont % \Huge % replaced
    \ #1\par\nobreak
    \vskip 0\p@
    \noindent\rule{\textwidth}{2pt}
}}
\makeatother

\begin{document}

\chapter{Chapter}

\end{document}

enter image description here

  • With \rule it's perfect, but with \hrulethere is no space between the bottom line and the next text line. Any fix to this? – Daniel Apr 9 at 13:15
  • 1
    Add again \vskip 20\p@ after last \hrule. – ferahfeza Apr 9 at 13:18

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.