How to center the minipage?
Put it inside a centered box
\documentclass{article}
\begin{document}
\noindent\hrulefill\par
\noindent\makebox[\textwidth][c]{%
\begin{minipage}{1.5\textwidth}
\hrulefill\par
\end{minipage}}
\end{document}
A simple way to do this is to use \centerline{..}
around the minipage
. (This does not allow for verbatim or similar special content, but there is a \Centerline
variant from the realboxes
package, which does!)
I would add some small or medium vertical skip before and after this minipage
to get decent vertical spacing.
\documentclass{article}
\usepackage{lipsum}% dummy text
\begin{document}
\lipsum[1]
\par\smallskip\noindent
\centerline{\begin{minipage}{1.5\textwidth}
\lipsum[2]
\end{minipage}}
\par\smallskip
\lipsum[3]
\end{document}
Another easy way is to use the adjustbox
environment from the package with the same name. It provides the keys minipage=<minipage args>
, center
(=<length>
, normally \linewidth
) and also margin
(=<left/right> <top/bottom>
, and more).
\documentclass{article}
\usepackage{adjustbox}
\usepackage{lipsum}% dummy text
\begin{document}
\lipsum[1]
\begin{adjustbox}{minipage=1.5\textwidth,margin=0pt \smallskipamount,center}
\lipsum[2]
\end{adjustbox}
\lipsum[3]
\end{document}
Compare the similar question and answers at How can I center a too wide table?.
I was putting parcolumns and verbatim blocks inside my minipage which was causing problems. I found this rather simple solution quite effective:
\noindent\hspace{0.15\linewidth}\begin{minipage}{0.7\linewidth}
...
\end{minipage}
This creates a smaller minipage and centres with a positive hspace. Using the rule hspace = (1\linewidth - minipage_width) / 2
will also work for values larger than \linewidth
and produce a negative hspace:
\newlength{\myminipagewidth}
\newlength{\myminipagecentering}
\setlength{\myminipagewidth}{1.5\linewidth} %change this
\setlength{\myminipagecentering}{(\linewidth-\myminipagewidth)/2}
\noindent\hspace{\myminipagecentering}\begin{minipage}{\myminipagewidth}
...
\end{minipage}
(sub \linewidth
with \textwidth
when needed)