3

I would like to add a border to the left of some indented text, eventually spanning several pages and nested. My goal is similar to Indentation level inside proof but the solution I found back that time was not working on text spanning several pages. For what I tried, mdframed and tcolorbox have issues with nested boxes spanning several pages (for example the inner box starts on a new page).

Meanwhile, I found the command adjustwith that let me indent my text in a pretty simple and robust way. But I still don't know how to add a vertical line to the left of the text.

Here is what I want:

enter image description here

And what I have so far:

enter image description here

MWE:

\documentclass{article}
\usepackage{changepage}% http://ctan.org/pkg/changepage
\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\newenvironment{subproof}{\begin{adjustwidth}{2.5em}{0pt}}{\end{adjustwidth}}

\begin{document}
\section{Title}
I would like to add a black border on the left of all ``adjustwidth'' blocks:
\begin{subproof}
  \lipsum[1]
  \begin{subproof}
    \lipsum[1-2]
    \[\Delta = b^2 - 4ac\]
    \lipsum[1-2]
  \end{subproof}
  \lipsum[1]
\end{subproof}
\lipsum[1]
\end{document}

EDIT: I just heard of the changebar package, and it does something quite close to the thing I want... except that I can't find how to change the position of the line several times. Indeed, if I change \changebarsep after the beginning of the document, the lines position are not changed... I was thinking to modify the package to my need, but I'm not sure to see yet how to do...

EDIT2:

The proposition of muzimuzhi does not work, because when the nested subproof is larger than a page, it it moved to the next page (leaving a bit blank in the first page), and the bars are a bit ugly as on the next page the inner bars are longer than the outer bars:

enter image description here

Code to produce this result:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}

\newtcolorbox{lmarginbox}{
  blanker, breakable, left=2.5em,
  borderline west={1pt}{0pt}{black}}

\begin{document}
\lipsum[33]

\begin{lmarginbox}
  \lipsum[1-2]
  \begin{lmarginbox}
    \lipsum[1-5]
  \end{lmarginbox}
  \lipsum[4-5]
\end{lmarginbox}

\lipsum[33]
\end{document}

-- EDIT 3 --

I found also this answer which seems to provide some tricks to draw lines between several pages using tikz. I guess it could be a solution...

0

A tcolorbox attempt

\documentclass{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}

\newtcolorbox{lmarginbox}{
  blanker, breakable, left=2.5em,
  borderline west={1pt}{0pt}{black}}

\begin{document}
\lipsum[33]

\begin{lmarginbox}
  \lipsum[1-2]
  \begin{lmarginbox}
    \lipsum[3]
  \end{lmarginbox}
  \lipsum[4-5]
\end{lmarginbox}

\lipsum[33]
\end{document}

Noticed that you use an environment name subproof. If you want to redefine a theorem-like environment, see examples in tcolorbox's documentation, sec. 17.4.

| improve this answer | |
  • Thanks, but this solution does not work because when the nested lmarginbox goes to the next page, it it moved to the next page. See my edit for a screenshot. – tobiasBora Mar 24 at 10:52
  • @tobiasBora Ah yes. tcolorbox cannot handle nested breakable boxes well. See Breakable nested tcolorbox. – muzimuzhi Z Mar 24 at 12:52

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.