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.

    enter image description here

The corresponding code is given by,


    body of text 

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

    body of text 




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!

  • 1
    Please, make a complete example, not just a code snippet. Without the definition of exmp it's impossible to give advice.
    – egreg
    Dec 15, 2015 at 21:32
  • @egreg Apologies, that should clear things up? Dec 15, 2015 at 21:34
  • 1
    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}
    – Zarko
    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

1 Answer 1


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{...}


 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,
\addplot[smooth,<->,shift={(-2mm,2mm)}] coordinates  {
    (0.5,0.25) (1.5,0.5) (2.5,0.5) (4,0.65)};
\addplot[smooth,thick,o-o] coordinates  {
    (0.5,0.25) (1.5,0.5) (2.5,0.5) (4,0.65)  (6,0.8)};
\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)$};

By this code is obtained image without background.

enter image description here

  • Wow! this is a fantastic answer, I can't thank you enough! :D Dec 16, 2015 at 0:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .