6

I understand the spacing=true option in microtype is considered "experimental". However, for my document it does improve the appearance of the document -- with the dramatic exception of certain minipages when ragged2e is also used.

\documentclass{article}
\usepackage[document]{ragged2e}
\usepackage{mdframed}

\usepackage[spacing=true]{microtype}

\newenvironment{mybox}{
\begin{minipage}[\textheight]{\linewidth}
\begin{mdframed}
}{
\end{mdframed}
\end{minipage}
}

\usepackage{lipsum}

\begin{document}

\begin{mybox}
\lipsum[1-3]
\end{mybox}

\end{document}

enter image description here

What is the best solution (aside from the default spacing=false)?

3
  • 1
    I get no issue if I add the \RaggedRight declaration at the start of the mdframed environment.
    – egreg
    Oct 12, 2016 at 22:32
  • That's true for this example; however, in general that didn't seem to solve the problem. I'll try to produce an example.
    – Hugh
    Oct 12, 2016 at 22:36
  • 2
    Well, microtype warns you that with ragged2e something bad can happen.
    – egreg
    Oct 12, 2016 at 22:45

1 Answer 1

5

The microtype package issues a warning:

Package microtype Warning: You are using the `ragged2e' package.
(microtype)                Adjustment of interword spacing may lead to
(microtype)                undesired results when used with `ragged2e'.
(microtype)                In this case, disable the `spacing' option.

However, there's no wrong output if I restate \RaggedRight at the beginning of the mdframed environment.

\documentclass{article}
\usepackage[document]{ragged2e}
\usepackage{mdframed}

\usepackage[spacing=true]{microtype}

\newenvironment{mybox}
 {\begin{minipage}[\textheight]{\linewidth}
  \begin{mdframed}\RaggedRight}
 {\end{mdframed}\end{minipage}}

\usepackage{lipsum}

\begin{document}

\noindent
\begin{mybox}
\lipsum[1-3]
\end{mybox}

\end{document}

It's not clear what's the role of the minipage wrapper, though.

enter image description here

If you want that the framed box is not split across pages, just add the nobreak option.

\newenvironment{mybox}
 {\begin{mdframed}[nobreak]\RaggedRight}
 {\end{mdframed}}

This also avoids the need of \noindent.

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.