5

I have been looking at re-defining minipage so that it is always raggedright but that looks problematic because of the optional arguments. I have a long document which uses lots of minipages. I would like to make them all raggedright inside. Is there any way to do this?

The code below does not do what I want because it is not raggedright inside the minipage

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\raggedright

\begin{minipage}{0.4\linewidth}
\lipsum[3]
\end{minipage}

\end{document}
5

You can use the \@minipagerestore hook:

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\let\@minipagerestore=\raggedright
\makeatother

\begin{document}

\lipsum[4]
\noindent
\begin{minipage}[t]{0.4\linewidth}
\lipsum[3]
\end{minipage}

\end{document}

enter image description here

Another option is to patch \@iiiminipage:

\documentclass{article}
\usepackage{lipsum}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@iiiminipage}
  {\@setminipage}
  {\@setminipage\raggedright}
  {}
  {}
\makeatother

\begin{document}

\lipsum[4]
\noindent
\begin{minipage}[t]{0.4\linewidth}
\lipsum[3]
\end{minipage}

\end{document}
  • I used the \@minipagerestore hook. It worked beautifully. Thank you so much! – Hilary Sep 25 '15 at 8:29

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.