[Tex/LaTex] Framing section headings

framedmdframedsectioning

I'm attempting to put a frame around my section headings. I am using the package mdframed which adds functionality to the framed package. It basically draws a box around an object, in an environment. So I wonder how I can do this. Can I use \renewcommand, for example? I'd really like to use mdframed to create the frame.

Best Answer

The titlesec package provides this functionality built-in. Here's an example:

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[frame]
{\normalfont} {} {5pt} {\Large\bfseries\filcenter\thesection.\quad}
\begin{document}
\section{A section}
\end{document}

enter image description here

If this isn't what you want, you should probably use the package in conjunction with mdframed to modify your sections anyway, since it provides a simple, yet powerful system for modifying all section headings.