I'm trying to put a box around a section, both the title and the contents. I've found ways of doing one or the other, but not both.

| Title                 |
|                       |
| content of section    |
| ...                   |

Something like the above, a single box around both the section title, and the section content.


Try the mdframed package.

\section{This is a framed section}
This is the text.


| improve this answer | |
  • Tried that. Ended up with strange results. Some sections had to lines, others did not. Some had left lines, others did not. Some had bottom lines, others did not. No single section had four lines all the way around it. Actually, on closer look, the lines do go all the way around, but such a thin line that Adobe Acrobat does not render the line in all cases. How can I make the line thicker? – AgilePro Oct 22 '16 at 19:57
  • 1
    Use something like \begin{mdframed}[linewidth=5pt] (see the mdframed package documentation for details). – Ian Thompson Oct 24 '16 at 22:51

Another option, using the tcolorbox package:



\section{A test section}
\begin{tcolorbox}[breakable,colback=white,colframe=cyan,width=\dimexpr\textwidth+12mm\relax,enlarge left by=-6mm]
\section{A framed test section}


enter image description here

| improve this answer | |

Here's a solution using ConTeXt. First a text background is defined using \definetextbackground. In contrast to a \framed, the text background permits page breaks. All options except location are optional. The background is then hooked into the chapter.

\setuppapersize [A6]  %% only for the screenshot



  \startchapter [title=Lorem ipsum dolor…]
    \input knuth


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.