Since exercise numbers are in the left margin, I would like to extend this colored background into the left margin only (not the right!) by a centimeter or two. And still keep the text "Exercises section~\thesection" centered.
Is there any way to do that? I tried adding negative space on the left with
\titlespacing*
, or extending \textwidth
, but that doesn't do the trick.Code: Select all
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{ntheorem}
\newcommand\problems
{
\begingroup
\titleformat{\section}
{\normalfont\sffamily\filcenter}
{}
{0pt}
{\tikz[baseline]{\node[fill=blue!20,text=black,minimum width=\textwidth]{##1};}}
\section*{Exercises section~\thesection}
\endgroup
}
\theoremstyle{margin}
\theoremheaderfont{\small\bfseries}
\theorembodyfont{\small}
\theoremsymbol{}
\newtheorem{exercise}{}[section]
\begin{document}
\section{First section}
\lipsum[1]
\problems
\begin{exercise}
First question
\end{exercise}
\end{document}