6

I would like to create a text box of "reminders" for my readers. I'd like the box to be gray, go full text width, and have both normal and verbatim text in it.

Reminder

ensure blah blah \underline{before} running \verb!-egrmaclean-!. 
make blah blah ``\emph{2. TEMP filename.dta}'' \emph{2. country project.do} file. 

1 Answer 1

9

You can use the mdframed package. A simple example (please refer to the package documentation to learn all the possibilities for customization offered by the package):

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\newmdenv[
  backgroundcolor=gray!20,
  frametitle=Reminder,
  skipabove=\topsep,
  skipbelow=\topsep,
]{reminder}

\begin{document}

\lipsum[2]
\begin{reminder}
ensure blah blah \underline{before} running \verb!-egrmaclean-!. 
make blah blah ``\emph{2. TEMP filename.dta}'' \emph{2. country project.do} file.
\end{reminder}
\lipsum[2]

\end{document}

enter image description here

Another option would be to use the framed package:

\documentclass{article}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{lipsum}% just to generate text for the example

\colorlet{shadecolor}{gray!20}

\newenvironment{myshaded}
  {\def\FrameCommand{\fboxsep=\topsep\colorbox{shadecolor}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}

\newenvironment{reminder}
  {\begin{myshaded}\noindent\textbf{Reminder}\par\nobreak\noindent\ignorespaces}
  {\end{myshaded}}

\begin{document}

\lipsum[2]
\begin{reminder}
ensure blah blah \underline{before} running \verb!-egrmaclean-!. 
make blah blah ``\emph{2. TEMP filename.dta}'' \emph{2. country project.do} file.\end{reminder}
\lipsum[2]

\end{document}

enter image description here

3
  • Thanks Gonzalo. Any idea what this error means? I'm guessing that it has to do with not having the mdframed package installed, but I'm kinda new, and the videos on youtube dont't seem to help much. ! LaTeX Error: File `mdframed.sty' not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty)
    – Michael
    Nov 29, 2012 at 4:30
  • @Michael yes, the error indicates that the package is missing in your system. Depending on your LaTeX distribution, you could use the packagemanager to install it; if there's no package manager available, then you could try installing it manually from mdframed in CTAN (this could be time consuning due to possible unresolved dependencies). I updated my answer with another option, using the framed package which should be in your system. By the way, you should consider doing an updated and complete LaTeX installation. Nov 29, 2012 at 5:03
  • @GonzaloMedina If I want verbatim text only inside the box, how can I set this in \newmdenv? Thank you. Oct 3, 2017 at 10:23

You must log in to answer this question.

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