0

How can I define an environment that looks like the following?

enter image description here

So there's a color surrounding box and an image embedded in it. This is what I have so far:

\newenvironment{rmd-details}[0]{\par\leftskip=2em\rightskip=2em}{\par\medskip}

This is mostly placeholder material, just to confirm that all the .tex files build into something. This is nowhere near what I want it to look like, though.

2
  • 1
    check the tcolorbox documentation. Commented Nov 30, 2021 at 18:51
  • Not exactly the same look, but check out awesomebox and its \tipbox.
    – Skillmon
    Commented Nov 30, 2021 at 19:55

2 Answers 2

3

This solution uses \fbox and a minipage. I arbitrarily chose 5pt for the border.

I placed the icon into a fixed width box, similar to how \item works. If you change symbols, the width doesn't change.

\documentclass{article}
\usepackage{xcolor}
\usepackage{fontawesome}
\usepackage{blindtext}% MWE only
%\usepackage{showframe}% MWE only

\newsavebox{\bulb}% bulb+gap=0.25in
\savebox{\bulb}{\makebox[0.25in][l]{\huge \faLightbulbO}}

\newsavebox{\rmdbox}
\newenvironment{rmd-details}{\fboxsep=5pt
  \begin{lrbox}{\rmdbox}
  \minipage[c]{\dimexpr \textwidth-2\fboxsep-2\fboxrule-\wd\bulb}}%
{\endminipage\end{lrbox}%
  \par\noindent\color{green}\fbox{\usebox\bulb\usebox\rmdbox}\par}
  
\begin{document}

\begin{rmd-details}
  \blindtext
\end{rmd-details}

\end{document}

demo

1
  • You are right! The simplicity of the design is probably indeed an argument for not loading the tcolorbox package … Commented Nov 30, 2021 at 19:20
3

Relatively easy to achieve with the package tcolorbox (as Ulrike Fischer already pointed out):

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins} 

\usepackage{fontawesome}

\newtcolorbox{rmd-details}{
    enhanced,
    sharp corners,
    colframe=green,
    colback=white,
    left=1cm,
    overlay={%
        \node at ([xshift=18pt]frame.west) {\Huge\faLightbulbO};
    },
}

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{rmd-details}
\lipsum[1]
\end{rmd-details}

\end{document}

enter image description here

It would even be possible to make these boxes breakable. But, you would need to decide about the position of the lightbulb then ...

1
  • this is great thanks
    – Taylor
    Commented Nov 30, 2021 at 22:27

You must log in to answer this question.

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