0

I'm trying to put a frame box around ALL e table of contents in an article document class. Someone can help me?

1
2

Depending on how big your ToC is, the following works without any packages (duckuments is only loaded to quickly produce a few pages of contents with sections and subsections).

Small ToC (no need for column or page breaks)

This solution will only work as long as your ToC fits on a single page/in a single column.

You can change the rule thickness of the box by using \setlength{\fboxrule}{<your length>}, and change the distance between the frame and the contents by using \setlength{\fboxsep}{<your length>} (best done in a group around \fbox to not change anything else in the document, e.g., \begingroup\setlength{\fboxrule}{1cm}\fbox{...}\endgroup).

\documentclass[]{article}

\usepackage{duckuments}

\begin{document}
\noindent
\fbox
  {%
    \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule}%
      \tableofcontents
    \end{minipage}%
  }%

\duckument
\end{document}

enter image description here

Bigger ToC (or fancy boxes)

If your ToC requires to be page breakable, you can use the tcolorbox package and its breakable library. The following is an example which uses the default looks of a tcolorbox (but tcolorbox is really customisable, so you can achieve almost any looks you could imagine with this, this includes a plain looking frame as done with \fbox)


\documentclass[]{article}

\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\usepackage{duckuments}

\begin{document}
\noindent
\begin{tcolorbox}[breakable]
  \tableofcontents
\end{tcolorbox}

\duckument
\end{document}

enter image description here

1
  • That's great! Thank you so much!
    – mcp
    Oct 17 '20 at 13:36

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.