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.

2
  • 1
    Why don't you want to use titlesec?
    – user156344
    Apr 9, 2019 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, 2019 at 12:22

1 Answer 1

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

2
  • 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, 2019 at 13:15
  • 1
    Add again \vskip 20\p@ after last \hrule.
    – user31034
    Apr 9, 2019 at 13:18

You must log in to answer this question.

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