1

I am trying to get a background on theorems and such extending onto the outer margin of a two-sided document, using the interface provided by thmtools.sty to mdframed.

There is a catch, though: mdframed deals with inner and outer margins of a two-sided document using the options innermargin and outermargin, and that works nicely… but to get what would be the padding in CSS I was using the options innerleftmargin and innerrightmargin right before I turned my document into a two-sided one, and there is no innerinnermargin/inneroutermargin options to do this two-sidedly.

For example, consider:

\documentclass[twoside]{article}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[showframe]{geometry}

\mdfdefinestyle{style}{%
  hidealllines=true,
  backgroundcolor={red!50},
  innermargin=-0pc,
  outermargin=-6pc,
  innerleftmargin=0pc,
  innerrightmargin=6pc
}

\begin{document}

\begin{mdframed}[style=style]
\lipsum[1]
\end{mdframed}

\newpage

\begin{mdframed}[style=style]
\lipsum[1]
\end{mdframed}

\newpage

\begin{mdframed}[style=style]
\lipsum[1]
\end{mdframed}

\end{document}

which produces

enter image description here

I don't think mdframed has this built in.

Can anyone provide a quick hack to do this?

  • 2
    Why don't you use tcolorbox? – Ulrike Fischer Mar 16 '18 at 23:10
  • @Ulrike, How does one do this with tcolorbox? – Mariano Suárez-Álvarez Mar 17 '18 at 8:05
  • By looking in the documentation. – Ulrike Fischer Mar 17 '18 at 8:40
  • @UlrikeFischer, before asking you that I spent an hour playing with oversize/enlarge left by/grow to left by/toggle left and right/toggle enlargments/left/right and a few of the other hundreds of options tcolorbox has and was not able to get a box overspilling to both margins larger on the outer one in which text is set as normal. But thank you. That was very helpful. I would have never thought of reading the docs. – Mariano Suárez-Álvarez Mar 17 '18 at 19:30
1

With tcolorbox you can do it like this:

\documentclass[twoside]{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[showframe]{geometry}


\begin{document}

\begin{tcolorbox}[grow to right by=2cm,if odd page={right=2cm}{left=2cm},toggle enlargement]
\lipsum[1]
\end{tcolorbox}

\newpage

\begin{tcolorbox}[grow to right by=2cm,if odd page={right=2cm}{left=2cm},toggle enlargement]
\lipsum[1]
\end{tcolorbox}

\newpage

\begin{tcolorbox}[grow to right by=2cm,if odd page={right=2cm}{left=2cm},toggle enlargement]
\lipsum[1]
\end{tcolorbox}

\end{document}

enter image description here

  • This works, thanks. If a box is breakable and actually gets broken across a pagebreak, then the second half gets the same margins as the first half — which are the wrong ones. I guess this is something that should be fixed in tcolorbox? – Mariano Suárez-Álvarez Mar 18 '18 at 5:07
  • You can see this by changing the [1] in the first \lipsum to [1-10], adding the breakable option to the \usepackage{tcolorbox}, and the breakable option to the tcolorboxes. – Mariano Suárez-Álvarez Mar 18 '18 at 5:10
  • It can be done with breakable boxes too but better ask a new question so that others can answer it too. I have no time now. – Ulrike Fischer Mar 18 '18 at 7:35

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.