39

The left margin is too wide if I set 1.5\textwidth:

\begin{document}

\noindent\begin{minipage}{1.5\textwidth}

test

\end{minipage}

\end{document}

4 Answers 4

52

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}
5
  • I think \linewidth should be used instead of \textwidth per this post about the difference between these two May 18, 2011 at 3:38
  • @Peter Grill: The OP asked for \textwidth and it is difficult to say without context what it is used for. If you are looking for a fixed global width it is \textwidth. If the widths need to change with local column, environment of box width, then use \linewidth
    – Danie Els
    May 18, 2011 at 4:02
  • This response not works fine for msupertabular environment.
    – juanuni
    May 21, 2015 at 5:24
  • 1
    This doesn't quite work if you put two minipages in it.
    – yujaiyu
    May 13, 2020 at 16:12
  • It worked for my case with three minipages. Thanks! Jul 3 at 14:35
17

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?.

2
  • 2
    It should be noted that using \centerline is deprecated in LaTeX (at least according to the l2tabu document).
    – mhp
    Apr 13, 2012 at 13:18
  • 1
    @mhp: Thanks, I was not aware of that. I find it very useful from time to time. Looking at l2tabu it stated that it should not be used to center text, because it e.g. can cause issues when used inside lists. I think it is fine for this case, i.e. a large block in a paragraph of it's own. Apr 13, 2012 at 13:19
5

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)

-1

Very simple, enclose that minipage in center using \begin{center} and \end{center} as shown below:

\begin{center}

\noindent\begin{minipage}{1.5\textwidth}

text

\end{minipage}

\end{center}
2
  • 1
    The center environment will not center content that is wider than the textwidth. \documentclass{article} \usepackage{lipsum} \begin{document} \lipsum[1] \begin{center} \begin{minipage}{1.5\textwidth} \lipsum[4] \end{minipage} \end{center} \lipsum[4] \end{document} will result in i.stack.imgur.com/ZdtEI.png
    – leandriis
    Mar 22, 2020 at 11:22
  • Still, it remains useful in more "regular", simpler cases.
    – Eusebius
    Mar 5, 2022 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .