I have been successful at creating a set of Warning, Note, and Info boxes using mdframed package, and they look very good. However, I need to left align an inserted image rather than have it on its own line above the text, but below the frame title.
In fact, this question (and excellent answers!) got me where I am now: Rounded box with image and text. However, I need to modify the resultant box as described in my first paragraph (image left aligned and text to the right, but with the frametitle above the image). Here is what I have so far (I hope it is MWE, as I am not sure how to reference an external image in this example):
\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{lipsum}% Used for dummy text.
\definecolor{warning}{RGB}{255,231,231}
% Definition for Warning Boxes
\mdfdefinestyle{warn}{roundcorner=10pt,
skipabove=10pt
skipbelow=10pt
leftmargin=20pt,
rightmargin=20pt,
backgroundcolor=warning,
innertopmargin=10pt,
innerbottommargin=10pt,
innerleftmargin=10pt,
middlelinewidth=0pt,
everyline=true,f
linecolor=warnline,
font=\normalfont\normalsize,
shadow=true,
frametitlefont=\normalfont\normalsize\bfseries,
frametitleaboveskip=1em,
}
\begin{document}
\begin{mdframed}[style=warn, frametitle=Warning]
\includegraphics[scale=0.50]{<path>/<icon>} \\ Important warning not to be missed.
\end{mdframed}
\end{document}
It is important also that I can insert this Warning note by a simple line such as
\begin{warning}
This is the warning text.
\end{warning}
Thanks in advance for your assistance.
Best Answer
You can achieve what you want simply modifying the settings you were using and taking advantage of
singleextra
,firstextra
to place the title and the image.Notice that you had the default
framemethod
, so some of your settings were silently ignored; to prevent this, I changed toframemethod=tikz
(I also defined awarnline
color that was missing on your original code).Instead of defining a style, as in your code, I defined an environment using
\newmdenv
; this allows you to simply use your desired syntax:The code (adjust the lengths according to your particular needs):
The
demo
option forgraphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.