Text FormattingChapter style

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
pwiecek
Posts: 1
Joined: Sat Nov 06, 2010 12:11 pm

Chapter style

Post by pwiecek »

I would like to have something like that:

Introduction 1
-----------------------

but the number should be bigger then chapter name. The chapter name and number should be in the same line...

I found:

\documentclass{sample}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@
{\raggedleft \reset@font
\fontsize{15ex}{15ex}\selectfont %Problème avec les substitutions...
\bfseries\thechapter\par\nobreak}%
\par\nobreak
\interlinepenalty\@M
{\raggedright \Huge \bfseries #1}%
\par\nobreak
\hrulefill
\par\nobreak
\vskip 100\p@
}}
\def\@makeschapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@
{\raggedleft \reset@font
\fontsize{15ex}{15ex}\selectfont %Problème avec les substitutions...
\bfseries\vphantom{\thechapter}\par\nobreak}%
\par\nobreak
\interlinepenalty\@M
{\raggedright \Huge \bfseries #1}%
\par\nobreak
\hrulefill
\par\nobreak
\vskip 100\p@
}}
\begin{document}
\chapter{Introduction}
\end{document}



It's quite ok, but the number is not at the same line as chapter name...

Please help;)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Chapter style

Post by meho_r »

You may always manually set distances. A quick example using titlesec and graphicx (provides \scalebox command):

Code: Select all

\documentclass{report}

\usepackage{graphicx}

\usepackage[noindentafter]{titlesec}

\titleformat{\chapter}
   {\Huge\bfseries}% global formatting (number and title)
   {}% number and its formatting
   {0pt}% spacing between number and title
   {}% optional (content between number and title)
   [\hrule\vspace{-41.5pt}\filleft\scalebox{2}{\thechapter}]% text/command after title
   
\titlespacing{\chapter}
   {0pt}% left
   {2cm}% before
   {1cm}% after

\begin{document}

\chapter{Introduction}

Some text\ldots

\chapter[A little bit longer chapter title]{A little bit longer\\chapter title}

Some text\ldots

\end{document}
In case of longer chapter titles, you'll have to manually control line breaks and use optional titles for TOC and headers.
Post Reply