[Tex/LaTex] How to create specific section style using titlesec

fontsizesectioningtitlesec

I would like to create section style like in the attached picture, but I didn't find any way how to do it. Usually I'm using titlesec package for section style customizing.

section style

Is there any way how to move the section number to the right edge and make it larger than 'Huge'?

Thank you for your answers.

Jane

Best Answer

Here's one possibility using the titlesec package; adjust the settings according to your needs:

\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{fix-cm}
\usepackage{lipsum}

% numbered
\titleformat{\chapter}
  {\normalfont\LARGE\bfseries\filleft}
  {}
  {0em}
  {%
    \parbox[b]{\dimexpr\linewidth-2.5cm\relax}{#1}\hfill%
    \parbox[b]{2cm}{\hfill{\fontsize{80}{96}\selectfont\thechapter}}%
  }
% unnumbered
\titleformat{name=\chapter,numberless}
  {\normalfont\LARGE\bfseries\filleft}
  {}
  {0em}
  {\parbox[b]{\dimexpr\linewidth-2.5cm\relax}{#1}}
% spacing
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}

\begin{document}

\chapter{Introduction}
\lipsum[4]
\chapter*{Unnumbered chapter}
\lipsum[4]

\end{document}

enter image description here

Remarks

  • The question mentions sections, but the image suggests chapters; in any case, to have the formatting for sections, change chapter to section everywhere in my code.

  • To have larger font sizes, you need an scalable font, and then you can use

      \fontsize{<size>}{<baselineskip>}\selectfont
    
  • Two side-by-side \parboxes were used for numbered chapter titles; the first one for the title (accessed through #1 with the explicit option for titlesec) and the second one for the number. The boxes are bottom aligned so, for longer titles, the baseline of the number will be aligned with the baseline of the last line of the title.