TransWikia.com

Formatting chapter header with titlesec

TeX - LaTeX Asked on July 2, 2021

Im having troubles in formatting chapter headings. Im doing it with the package titlesec. My goal is to have the chapter number on the left, than a line with above the chapter name. I achieved this with the following minimal working example. But I can not figure out how to increase the size of the chapter name in this code?

RequirePackage{filecontents}
begin{filecontents*}{test1.tex}
    chapter{Chapter One}
    Text123
    Text123
    Text123
end{filecontents*}

documentclass[a4paper, liststotoc, bibtotoc, 12pt, numbers=noenddot, twoside]{book} 

usepackage{fancyhdr}

usepackage[explicit]{titlesec}
newlengthchapnumb
setlengthchapnumb{4cm}
titleformat{chapter}[block]
{normalfontsffamily}{}{0pt}
{parbox[b]{chapnumb}{%
        fontsize{100}{10}selectfontthechapter}%fontsize number
    parbox[b]{dimexprtextwidth-chapnumbrelax}{%
        raggedleft%
        hfill{LARGE#1}
        rule{dimexprtextwidth-chapnumbrelax}{0.4pt}}}
titleformat{name=chapter,numberless}[block]
{normalfontsffamily}{}{0pt}
{parbox[b]{chapnumb}{%
        mbox{}}%
    parbox[b]{dimexprtextwidth-chapnumbrelax}{%
        raggedleft%
        hfill{LARGE#1}
        rule{dimexprtextwidth-chapnumbrelax}{0.4pt}}}

begin{document}
    include{test1}
end{document}

Many thanks for your help!!

One Answer

It was already suggested by Ivan, so credits for him.

x1

x2

RequirePackage{filecontents}
begin{filecontents*}[overwrite]{test1.tex}
    chapter{Chapter One}
    Text123
    Text123
    Text123
        chapter*{Chapter Two}
    Text123
    Text123
    Text123
    
end{filecontents*}

documentclass[a4paper, liststotoc, bibtotoc, 12pt, numbers=noenddot, twoside]{book} 

usepackage{fancyhdr}

usepackage[explicit]{titlesec}
newlengthchapnumb
setlengthchapnumb{4cm}
titleformat{chapter}[block]
{normalfontsffamily}{}{0pt}
{parbox[b]{chapnumb}{%
        fontsize{100}{10}selectfontthechapter}%fontsize number
    parbox[b]{dimexprtextwidth-chapnumbrelax}{%
        raggedleft%
        hfill{fontsize{50}{10}selectfont #1}  % <<<<<<<<<<<<<<<<<<
        rule{dimexprtextwidth-chapnumbrelax}{0.4pt}}}
titleformat{name=chapter,numberless}[block]
{normalfontsffamily}{}{0pt}
{parbox[b]{chapnumb}{%
        mbox{}}%
    parbox[b]{dimexprtextwidth-chapnumbrelax}{%
        raggedleft%
        hfill{fontsize{50}{10}selectfont #1} % <<<<<<<<<<<<<<<<<<
        rule{dimexprtextwidth-chapnumbrelax}{0.4pt}}}

begin{document}
    include{test1}
end{document}

Answered by Simon Dispa on July 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP