0

Is there a way to create a gray box around text that will split upon a page break? For example, using tcolorbox I can get the following:

enter image description here

However, it will shift onto the next page if it does not fit on the current page, and if it does not fit on a single page, it will run past the end of the page. I also do not want to manually do it because changing the content on previous pages would mess up the exact lining.

0

1 Answer 1

7

tcolorbox provides library breakable for automatically breaking boxes:

\documentclass{article}

\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\usepackage{mwe}

\begin{document}
\lipsum[1]

\begin{tcolorbox}[breakable,boxrule=0pt]
  \lipsum
\end{tcolorbox}

\lipsum[1]
\end{document}

two pages of document with box across two pages

See section 19 of the user manual for more information about breakable.

There are alternatives like mdframed or framed which provide similar feature for boxes with background across pages.

2
  • When I used breakable, the border where it breaks has very weird behavior, regardless of the tool I am using to view the pdf. At certain zoom levels, I will see a solid border, and at other levels I do not see it. I thought this might just be a result of pixel use, but it doesn't happen for other borders. Upon extreme zoom, I can see the slightest color change at the border. Is there a way to fix this?
    – user206144
    Commented Apr 18, 2023 at 11:43
  • @MikeSmith If you have a new question, please ask a new question. Currently I do not understand, whether you are talking about a viewer issue or problems in setting the color and width of a border or shadown.
    – cabohah
    Commented Apr 19, 2023 at 5:43

You must log in to answer this question.