# minipage within fullwidth

I'm using Marco Daniel's fullwidth package, detailed in this answer. I want all of my text in fullwidth to be inseparable (and to begin and end with long black lines), so I am currently doing the following:

\documentclass[11pt,a4paper]{memoir}

\usepackage[outermargin=-4cm,]{fullwidth}

\begin{document}

\begin{minipage}{\linewidth}
\begin{fullwidth}[width=\linewidth+4cm]
\medskip

This is very long, but because it is in the fullwidth environment,
it extends into the full length of the page
before a line break occurs.

\medskip
\end{fullwidth}
\end{minipage}

\end{document}


This works, but it does give me the following warnings:

" fullwidth uses option nobreak Warning: \def on input line 15"

"Package fullwidth Warning: The environment is empty (fullwidth) on input line 15."

along with an

"Overfull \hbox"...

These warning do not occur when I remove the minipage command. What is causing these warning, and how can I get rid of them?

Also, can I define a macro so that whenever I just write \begin{fullwidth}, LaTeX will automatically do \begin{minipage}{\linewidth} \begin{fullwidth}[width=\linewidth+4cm] \medskip?

UPDATE:

@cmhughes provided a perfect solution to the "define a macro" question. However, his use of the nobreak option in fullwidth instead of using minipage doesn't work. Here's the gist of the problem with it:

If I use [leftmargin = -4cm] OR [outermargin = -4cm], then the fullwidth text extends into the correct margin (the outer margin) on odd pages, and the incorrect margin (the inner margin) on even pages. If I use [rightmargin = -4cm] OR [innermargin = -4cm], then the fullwidth text extends into the correct margin (the outer margin) on even pages, and the incorrect margin (the inner margin) on odd pages. Herein lies the problem: the nobreak option messes up relative positioning, so that outermargin and innermargin only behave like leftmargin and rightmargin.

Please read the comments on his answer for a more detailed discussion. As of now, I'm looking for something that can fix the warnings given by using minipage, or that can use the nobreak option correctly...

-
If no one fixed the problem, what am I supposed to do with the bounty? –  jamaicanworm Feb 27 '12 at 19:39

Rather than using a minipage to stop the environment from being split, you can use the option nobreak.

In addition to this, rather than using \medskip you can use the options innertopmargin and innerbottommargin.

In the code below, I've inserted an artificial vspace just to test if the block stays together, and doesn't break across pages

\documentclass[11pt,a4paper]{memoir}
\usepackage{lipsum}
\usepackage[outermargin=-4cm,]{fullwidth}

\begin{document}

\lipsum[1]
\vspace{8.5cm}
\lipsum[1]
\begin{fullwidth}[innermargin=-2cm,width=\linewidth+4cm,nobreak]
This is very long, but because it is in the fullwidth environment,
it extends into the full length of the page
before a line break occurs.
\end{fullwidth}

\end{document}


You can create your own environment

\newenvironment{myfullwidth}{\begin{fullwidth}[width=\linewidth+4cm,nobreak]}%
{\end{fullwidth}}


which can be used as

\begin{myfullwidth}
\lipsum[2]
\end{myfullwidth}

-
The problem is that with the nobreak command, the fullwidth extends into the wrong margin. Try compiling your code as an example--now the text in fullwidth runs off the page (gets cut off), whereas it did not in my example. I assume it's getting confused about which margin (left or right) to extend into, since it's not sure what page (even or odd) it's on... –  jamaicanworm Feb 18 '12 at 17:26
When I compile your example exactly as it is written (including the use of outermargin at the top), the word "of" runs off the page. –  jamaicanworm Feb 18 '12 at 20:49
@jamaicanworm sorry for the delay (it seems the site was down for a while)- see my edit to include some compensation using innermargin –  cmhughes Feb 19 '12 at 1:04
Your example now compiles and the text is not cut off--however, the fullwidth text now extends into the inner margin, which I do not want. Again, the problem is that using nobreak for some reason switches the direction that the text extends into. (Using just \begin{fullwidth}[width=\linwidth+4cm] (as in my original example, without nobreak), the text extends into the correct direction.) –  jamaicanworm Feb 19 '12 at 16:58
@jamaicanworm: Then it's a bug and you should write me an e-mail. –  Marco Daniel Feb 20 '12 at 19:01

I'm not sure I really understand the problem, but if you want to put some unbreakable stuff in fullpage (or anything) I'd have expected the minipage to be inside the environment rather than outside it.

\begin{fullwidth}[width=\linewidth+4cm]
\noindent\begin{minipage}{\linewidth}


generates no warnings and produces a plausible output.

-
Thanks for the help! That more or less works, but in my big document, I'm now having the following problem: When the minipage forces a fullwidth chunk of text to stay together on the same page, for some reason it's creating a page break right after the fullwidth ends. (So the text that comes right after \end{fullwidth} somehow starts a new page.) This produces the warning: "Package fullwidth Warning: you got a bad break you have to change it manually by changing the text, the space or something else on line 416. Underfull \vbox (badness 10000) detected at line 416." –  jamaicanworm Feb 25 '12 at 20:13
If you have big boxes in your document without enough stretchy space between them, TeX can't find good page breaks. Without seeing the document hard to give advice, sometimes you either need to live with the bad break or re-order your document, or put the big box into a float so that latex can find somewhere more suitable to put it. –  David Carlisle Feb 25 '12 at 20:17
My main document is long and complicated, so unfortunately it wouldn't be feasible to post it here. The problem is that this error is occurring precisely in those places where minipage actually does anything. When I have text in fullwidth that would normally be broken up between pages, this setup spaces the rest of the text on that page in such a way that the fullwidth starts on a new page so that it is not broken up (good)--but then the text that follows fullwidth begins on a new page, even though there was remaining space on the page with the fullwidth text (bad)... –  jamaicanworm Feb 25 '12 at 20:30
as far as I can see fullwidth is basically a trivlist environment so as well as changing the margins it has display space before and after it, perhaps that is taking up the space where you expect the following text to go the documentation says there is a skipbelow option which you may want to set to 0. Just guessing... –  David Carlisle Feb 25 '12 at 20:45
Unfortunately that doesn't help. –  jamaicanworm Feb 26 '12 at 1:09