General ⇒ Color inside a minipage?
Color inside a minipage?
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..?
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
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?
Hi Bozack,
use \colorbox{color}{...}, you can set \parbox and even a minipage as argument into the box.
Stefan
use \colorbox{color}{...}, you can set \parbox and even a minipage as argument into the box.
Stefan
LaTeX.org admin
Color inside a minipage?
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:Stefan_K wrote:Hi Bozack,
use \colorbox{color}{...}, you can set \parbox and even a minipage as argument into the box.
Stefan
Code: Select all
\begin{center}
\colorbox{red}{
\fbox{
\begin{minipage}[t]{1.0\textwidth}
text
\end{minipage}
}
}
\end{center}
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
Color inside a minipage?
Hi Bozack,
change \fbox and \colorbox, set \fbox outside:
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
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}
Stefan
LaTeX.org admin
Re: Color inside a minipage?
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..
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
- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Color inside a minipage?
Oha.
You could remove the \fbox, but if you still want a frame around the colored box you can take \fcolorbox{black}{red}{...}
Stefan

Stefan
LaTeX.org admin
Re: Color inside a minipage?
There it was! Thank you so much
fcolorbox did the job to perfection

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
- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
Color inside a minipage?
... and you even can change the width of the frame line.
like this:
Stefan

Code: Select all
\setlength{\fboxrule}{1pt}
LaTeX.org admin
Re: Color inside a minipage?
faaancy 

OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
Color inside a minipage?
Hi! Who knows how to write a "newcommand" or a "newenvironment" that does what is described above?
E.G.:
The main problem is to include the minipage in the fbox (when you write a "newenvironment")
Thanks!
Andrea
E.G.:
Code: Select all
\begin{center}
\fcolorbox{black}{red}{
\begin{minipage}[t]{1.0\textwidth}
text
\end{minipage}
}
\end{center}
Thanks!
Andrea