GeneralColor inside a minipage?

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Color inside a minipage?

Post by Bozack »

Hi,

I've been trying to make boxes with a backgroundcolor including text and equations - and have found that the minipage environment does this kind of how I want it to. But I still haven't figured out how to make a background color inside a minipage.

Is there anyone who knows this? Or should I actually try with some different environment instead..?
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Re: Color inside a minipage?

Post by Stefan Kottwitz »

Hi Bozack,

use \colorbox{color}{...}, you can set \parbox and even a minipage as argument into the box.

Stefan
LaTeX.org admin
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Color inside a minipage?

Post by Bozack »

Stefan_K wrote:Hi Bozack,
use \colorbox{color}{...}, you can set \parbox and even a minipage as argument into the box.
Stefan
hmm, but when I use colorbox it makes the color go outside or inside the box I'we maked.. An example of my code might be appropriate:

Code: Select all

\begin{center} 
	\colorbox{red}{
		\fbox{
			\begin{minipage}[t]{1.0\textwidth} 
				text 
			\end{minipage}
		}
	} 
\end{center}
is there any way to make the color be only inside the fbox, but not to go too much inside (which makes a white frame inside the box)?
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Color inside a minipage?

Post by Stefan Kottwitz »

Hi Bozack,

change \fbox and \colorbox, set \fbox outside:

Code: Select all

\begin{center}
   \fbox{\colorbox{red}{
         \begin{minipage}[t]{1.0\textwidth}
            text
         \end{minipage}
      }
   }
\end{center}
This way you get the white frame. By the way, that example will produce a badbox (overfull \hbox), the width of the minipage should be reduced.

Stefan
LaTeX.org admin
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: Color inside a minipage?

Post by Bozack »

Oh, I think you misunderstood me. I don't want the color outside the box - OR the way so that it will make the white frame.. :P Is there any way to make the color simply stay inside the box and fill it all out?
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Re: Color inside a minipage?

Post by Stefan Kottwitz »

Oha. :) You could remove the \fbox, but if you still want a frame around the colored box you can take \fcolorbox{black}{red}{...}

Stefan
LaTeX.org admin
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: Color inside a minipage?

Post by Bozack »

There it was! Thank you so much :D

fcolorbox did the job to perfection :)
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Color inside a minipage?

Post by Stefan Kottwitz »

... and you even can change the width of the frame line. ;) like this:

Code: Select all

\setlength{\fboxrule}{1pt}
Stefan
LaTeX.org admin
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: Color inside a minipage?

Post by Bozack »

faaancy ;)
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
arota
Posts: 2
Joined: Wed Oct 08, 2008 1:30 pm

Color inside a minipage?

Post by arota »

Hi! Who knows how to write a "newcommand" or a "newenvironment" that does what is described above?
E.G.:

Code: Select all

\begin{center}
   \fcolorbox{black}{red}{
         \begin{minipage}[t]{1.0\textwidth}
            text
         \end{minipage}
      }
\end{center}
The main problem is to include the minipage in the fbox (when you write a "newenvironment")

Thanks!

Andrea
Post Reply