I'm having some difficulties to make something like that : I've been trying many things but I do not get anything like this...
Any ideas ?
Thanks

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
Code: Select all
\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}
% \titleformat{command}[form]{layout}{label-layout}{skip}{before-code}[after-code]
\renewcommand*\thesection{\arabic{section}.}
\newcommand\secformat[1]{%
\huge\colorbox{gray}{\parbox{\dimexpr\linewidth-6pt}{\bfseries\color{white}\thesection~#1}}}
\titleformat{\section}[block]{\normalfont\rmfamily}{}{0pt}{\secformat}
\usepackage{kantlipsum}% for some sample text
\begin{document}
\section{Introduction}
\kant[1-3]
\end{document}
\linewidth
is 6pt
too wide in the example above?You have to take the lengthcgnieder wrote:[…] PS: I'm sure I'm missing something obvious: does anybody know why\linewidth
is6pt
too wide in the example above?
\fboxsep
(default value 3pt) into account. It appears two times here so the width of your \parbox
should be \dimexpr\linewidth-2\fboxsep
.Of course! I feel stupid now ...localghost wrote:You have to take the length\fboxsep
(default value 3pt) into account.
\tableofcontent
?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