# Filling in colors in frame macros

I am hoping the answer to this question is a simple, so apologies for my ignorance. Based on posts here, I was finally able to make the frame appear the exact way I wanted it to. I made the following macro:

% make a box around text {framed}
\makeatletter
\renewenvironment{framed}{%
\def\FrameCommand##1{\hskip\@totalleftmargin
\fboxsep=\FrameSep\fbox{##1}
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\@totalleftmargin\z@ \linewidth\hsize
\@setminipage}}%
{\par\unskip\endMakeFramed}
\makeatother


I am now able to create frames around both my admonitions as well as my code. Here is an example:

My question is: is there a simple way to fill in the admonition frame (note) with yellow and the code frame with light gray? Thanks in advance.

• Hi ca nyou specify what post please so we can relate between ? and provide a MWE please – SAM Jul 1 '16 at 17:12
• From the xcolor package: \fcolorbox{<frame color>}{<background color>}{<text>}, but without an compilable example hard to test. – user36296 Jul 1 '16 at 17:17
• Or if you are not emotionally attached to your code fragment, there are great packages like tcolorbox which make it easy to add background colours to frames. – user36296 Jul 1 '16 at 17:19
• Also there is mdframed package. – Jagath Jul 1 '16 at 17:21
• @Jagath, I tried the mdframed package, but to no avail. For some reason it did not want to work on my system and TecnicCenter threw a rod. I have looked into it, but decided to try other methods rather than re-invent the wheel. Thanks for the suggestion. – Kerry Cox Jul 1 '16 at 19:17

Here's a tcolorbox version with sidebyside for the logo. Please note that such a box is not breakable!

\documentclass{article}
\usepackage[svgnames,dvipsnames,x11names]{xcolor}
\usepackage[most]{tcolorbox}

\usepackage[tikz]{bclogo}

\newtcolorbox{framed}[1][]{
colframe=lightgray,
colback=yellow!40!white,
enhanced jigsaw,
sharp corners,
lower separated=false,
lefthand width=1cm,
sidebyside gap=0.5cm,
sidebyside,#1}

\begin{document}

\begin{framed}
\bcbombe
\tcblower
To measure something use a ruler, a stop watch and scale!
\end{framed}

\begin{framed}[colback=blue!50!green]
\bclampe
\tcblower
Brontosaurs are thin at one end, thick in the middle and thin again at the other end!
\end{framed}

\end{document}


• I guess I should have been more specific. I have tried {tikz} and {mdframed} but they did not work on my specific set of .sty files. I am still relatively new at this and am using the Wiley LaTeX outline and also attempting to customize to my needs. Also, I would very much prefer keeping the frame the way I build it. My only complaint about the alternatives is that the horizontal space above and below the text is 3x what it should be. What I shared here is the best frame rendering so far. – Kerry Cox Jul 1 '16 at 19:22
• thanks for the suggestion. I will give that a shot and see if I can get better results using your syntax than my own. Vielen Dank! – Kerry Cox Jul 1 '16 at 19:29
• @KerryCox: The tcolorbox is very configurable. I think you will benefit from it! – user31729 Jul 1 '16 at 19:31
• yes, I am seeing that. Your code by itself works wonderfully. However, as I am trying to get a very specific look for my book, I am using the Wiley LaTeX template from Amy Hendrickson at Texnology. Her layout best matches what I want to display. However, I suspect her styles conflict with some of the packages you suggested. After adding your code and building to PDF, I have over 2800 errors. Maybe something other than TecnicCenter? I'd rewrite Amy's template if I were not such a neophyte. – Kerry Cox Jul 1 '16 at 19:44
• I don't use such stuff like TecnicCenter (that's an editor, isn't it?) You need to update your TeX distribution. Can you provide a link to this template. You should also be aware that redoing templates might conflict with copyright – user31729 Jul 1 '16 at 19:46

Very close to your code fragment, just replaces \fbox by \fcolorbox from the xcolor package:

\documentclass{article}

\usepackage{framed}
\usepackage{xcolor}
\usepackage{graphicx}

\definecolor{note}{rgb}{1 1 0.5}

\makeatletter
\renewenvironment{framed}{%
\def\FrameCommand##1{\hskip\@totalleftmargin
\fboxsep=\FrameSep\fcolorbox{black}{note}{##1}
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\@totalleftmargin\z@ \linewidth\hsize
\@setminipage}}%
{\par\unskip\endMakeFramed}
\makeatother

\begin{document}

\begin{framed}
\includegraphics[width=1cm]{bc-crayon} \texttt{Libstdc++} is part...
\end{framed}

\definecolor{note}{rgb}{0.8 0.8 0.8}

\begin{framed}
\includegraphics[width=1cm]{bc-outil} \verb|mkdir -r bla|
\end{framed}

\end{document}


I redefine the shaded environment from framed to have a frame, then define a note environment, based on ntheorem with option framed, as a shaded theorem:

\documentclass[english]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{geometry}%
\usepackage[x11names]{xcolor}
\usepackage{fourier, erewhon}
\usepackage{lipsum}
\usepackage{fontawesome}
\usepackage{amsmath}
\usepackage[thmmarks, thref, amsmath, framed]{ntheorem}
\input{insbox}
\newcommand\notesymbol{\relax}
\newtheoremstyle{note}%
{\item[]\leavevmode\InsertBoxL{0}{\enspace\textcolor{Tomato1}{\LARGE\notesymbol\,}}[2]\hspace*{-\parindent}}%
{\item[]\leavevmode\InsertBoxL{0}{\enspace\textcolor{Tomato1}{\LARGE\notesymbol\,}}[2]\hspace*{-\parindent}}%
\usepackage{framed}
\theoremstyle{note}
\colorlet{framecolor}{Grey0!80!RoyalBlue3!50!}
\theoremframepreskip{6pt}
\theoremframepostskip{6pt}
\theoreminframepreskip{4pt}
\theoreminframepostskip{4pt}
\theorembodyfont{\normalfont}
\theoremseparator{}
\def\notesymbol{\faFileText}