# Filling a color

I am having two problems with inserting an image into a mdframed environment. Both are documented in the attached picture.

1. Firstly the lines of text preceding and immediately after the inserted image are not aligned with the main body of text.
2. The second problem is that the background of the inserted image is white.

The corresponding code is given by,

\begin{exmp}
\mbox{}\par
\begin{mdframed}[backgroundcolor=blue!20]

body of text

\centering
\includegraphics[width=8cm, height=5cm]{RC}
\captionof{figure}{The generalised coordinates for our system. }

body of text

\end{mdframed}
\end{exmp}


With,

\theoremstyle{definition}
\newtheorem{exmp}{Example}[section]


defined in the preamble. A friend has assured me that there is a way to convert the image to a picture and then put it in a box and fill the colour of the box to the same as the background of the mdframed. Does anyone happen to agree with this?

I can move the inserted graphics around so that the alignment changes each time, if there is no sure fired way to fix this I always have this option.

The colour however is something I do not know where to begin with, that is, if it is even possible? An experts advice would be most welcomed and thank you for your time!

• Please, make a complete example, not just a code snippet. Without the definition of exmp it's impossible to give advice. Dec 15, 2015 at 21:32
• @egreg Apologies, that should clear things up? Dec 15, 2015 at 21:34
• hmm, to my opinion, the best will be redraw your image with som some latex drawing tool as mppost or pgf/TikZ. Otherwise you need to export your image without background (if this is possible in tool in which you draw the image). And by the way, after \centering all be centered. If you like to have centered only image, rather use begin{center} .. image .. \end{center} Dec 15, 2015 at 21:35
• @Zarko Thank you for the help! I see, how would I go about using the mppost or pdf/TikZ that you mentioned? Ah I realise I made a silly mistake with the centring! :) Dec 15, 2015 at 21:49
• Please complete your code so that it can be copy-paste-compiled. That is much more helpful than a mere fragment. That is, start with \documentclass and end with \end{document} in a single code block.
– cfr
Dec 15, 2015 at 22:13

Since background of your MWE is not know,, I can onla sugest how to draw showed image in TikZ. For it I use package pgfplots and for document class standalone To incorporate my picture in your real document, you need add into your document the code of tikzpicuture and in your document preamble package pgfplots with pgfplotsset{...} and \usetikzlibrtary{...}

\documentclass[border=3mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick = \empty,    ytick = \empty,
xlabel = {$t$},
x label style = {at={(1,0)},anchor=west},
ylabel = {$q$},
y label style = {at={(0,1)},rotate=-90,anchor=south},
axis lines=left,
enlargelimits=0.2,
]
\node[above=3mm] at (2.5,0.5) {$s$};
\draw[<->*]   (4,0.65) -- node[right] {$x$} (5.5,0.4) node[below] {point $(x,s)$};