2

I noticed that when I use mdframed in a memoir document I'm not able to change the margin lengths of any frame defined from mdframed. This appears to happen regardless of the place where I try to set their lengths.

Here is a MWE showing the problem.

\documentclass{memoir}

\usepackage[framemethod=tikz]{mdframed}

\definecolor{creamy}{HTML}{e2bf40}
\colorlet{callout-bg}{creamy!50}

\newmdenv[backgroundcolor=callout-bg]{newframed}

\begin{document}
    \begin{newframed}[leftmargin=-10pt, rightmargin=10pt]
        The leftmargin is \the\mdflength{leftmargin}. The rightmargin is \the\mdflength{rightmargin}.
    \end{newframed}
\end{document}

The actual used value is always 0.0pt

Is there a way to circumvent this unwanted interaction?

7
  • 2
    use tcolorbox instead of mdframed. Apr 22, 2021 at 21:07
  • @UlrikeFischer I need to be able to use colored framed paragraphs that can span multiple pages. Does tcolorbox allow for this usecase?
    – araruna
    Apr 22, 2021 at 23:07
  • 1
    @araruna that and much much more. IMO there isn't much reason to use mdframed any more
    – daleif
    Apr 23, 2021 at 4:58
  • I've removed the memoir tag
    – daleif
    Apr 23, 2021 at 4:59
  • 1
    Tcolorbox offers breakable boxes,and they are much more reliable than the one of mdframed. Mdframed has various problems here, e.g it can break to early or insert unwanted space. Apr 23, 2021 at 6:22

1 Answer 1

2

The issue is independent of memoir (the same happens with book). As explained in section 6.7 of the mdframed documentation you need the innermargin and outermargin options in two-side documents (the default mode for both memoir and book). Or alternatively you can use the leftmargin and rightmargin options but with the addition of the usetwoside=false option.

MWE

\documentclass{memoir}

\usepackage[framemethod=tikz]{mdframed}

\definecolor{creamy}{HTML}{e2bf40}
\colorlet{callout-bg}{creamy!50}

\newmdenv[backgroundcolor=callout-bg]{newframed}

\begin{document}
    
\begin{newframed}[innermargin=-10pt,outermargin=10pt]
 The leftmargin is \the\mdflength{leftmargin}. 
 The rightmargin is \the\mdflength{rightmargin}.
\end{newframed}

\begin{newframed}[usetwoside=false,leftmargin=-10pt,rightmargin=10pt]
 The leftmargin is \the\mdflength{leftmargin}. 
 The rightmargin is \the\mdflength{rightmargin}.
\end{newframed}    

\end{document}

enter image description here

1
  • This really solves the question. I saw this part on the manual and I indeed tried to use these options, but somehow they made no visual difference at first (10pt is not big enough) and I forgot to consider them in my "debug" MWE. Thank you.
    – araruna
    Apr 22, 2021 at 23:12

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.