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

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
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
?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