Text Formatting ⇒ Chapter and Section Style
Chapter and Section Style
Now I have a problem with the chapter and section style that I can not solve, and I couldn't find the solution. I hope someone here could help me.
My problem comes from the style of the section and chapter, specially the section. I want to fill the background of the section part, and I have no idea how to do this. I´ll upload a part of a document where you can see what I mean. I wish someone could help me to find the codes to make this kind of section and title.
Greetings from Spain.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
-
- Posts: 126
- Joined: Sun Feb 13, 2011 8:36 pm
Chapter and Section Style
I have tried to make an example that resembles what your picture looks like but there is surely much room for improvements.
Code: Select all
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{lipsum}
% Only these three packages are specific to the solution:
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{calc}
\definecolor{titlecolor}{HTML}{008B72}
\newcommand{\sectioncolorbox}[1]
{%
\setlength{\fboxsep}{1ex}%
\colorbox{titlecolor}%
{%
\begin{minipage}{\linewidth-2\fboxsep}
\sffamily\Large\slshape\color{white}%
\thesection.\quad#1
\end{minipage}
}%
}
\titleformat
{\chapter}
[block]
{\sffamily\huge\slshape\color{titlecolor}}
{\chaptertitlename~\thechapter.\hfill}
{0pt}
{\MakeUppercase}
\titleformat
{\section}
[block]
{}
{}
{0pt}
{\sectioncolorbox}
[]
\titlespacing*{\chapter}{0pt}{0pt}{*8}
\titlespacing*{\section}{0pt}{*10}{*4}
\renewcommand{\thesection}{\arabic{section}}
\begin{document}
\chapter{First Chapter}
\section{First Section Therein}
\lipsum
\section{Second Section Therein}
\lipsum[4]
\chapter{Second Chapter}
\lipsum
\end{document}
Best
Re: Chapter and Section Style
Thanks.
Blaze.