# How do you put a character in the margin (using an environment)

I'm using framed to create a little callout box for tips and other information in a book. So for it's going well however I cannot get the icon (using ding) to sit in the margin.

It currently looks like this:

whereas I'd like it to look like this mock up

I'm using the following code

\documentclass[a4paper,12pt]{article}
\usepackage{verbatim}
\usepackage{color}
\usepackage[english]{babel}
\usepackage{pifont}
\usepackage[strict]{changepage}
\usepackage{framed}
\usepackage{blindtext}

\newenvironment{tipbox}{%
\def\FrameCommand{%
{\Huge\ding{43} }
\hspace{1pt}%
{\color{green}\vrule width 2pt}%
}%
\noindent\hspace{-4.55pt}% disable indenting first paragraph
\vspace{2pt}\vspace{2pt}%
}
{%
}

\begin{document}

\blindtext

\begin{tipbox}
You can expect your organisation to perform better, but only if everyone pointing in the same direction.
\end{tipbox}

\blindtext

\end{document}


If putting it in the margin is too difficult, just moving the icon to the top of the box would be great :-)

• Welcome to TeX.sx! Please make sure that all images are uploaded using the official stackexchange interface, i.e. the image icon on top of the text field (shortcut: CTRL+G). This ensures that all images are always accessible and do not expire. As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. – Martin Scharrer Jun 6 '12 at 10:19
• Thanks for the feedback. I'll ensure I do that next time :-) – eleybourn Jun 6 '12 at 10:32

Here's a solution with mdframed

\documentclass{article}

\usepackage{mdframed}
\usepackage{pifont}
\usepackage{xcolor}

\usepackage{lipsum}

\newmdenv[
skipabove=\topskip,
skipbelow=\topskip,
innermargin=0pt,
outermargin=0pt,
innerleftmargin=4pt,
innerrightmargin=4pt,
innertopmargin=2pt,
innerbottommargin=2pt,
topline=false,
rightline=false,
bottomline=false,
linecolor=green,
linewidth=2pt,
]{tipbox*}
\newenvironment{tipbox}[1][43]
{\begin{tipbox*}
\makebox[0pt][r]{\smash{\raisebox{-.333\height}{\Large\ding{#1}\hspace{10pt}}}}\ignorespaces}
{\end{tipbox*}}

\begin{document}
\lipsum[1]

\begin{tipbox}
You can expect your organisation to perform better, but only if everyone is pointing in the same direction.

You can expect your organisation to perform better, but only if everyone is pointing in the same direction.
\end{tipbox}

\lipsum[2]
\end{document}


You can get a black hand with

\begin{tipbox}[42]


or use the number of any symbol you want.

• Great stuff. I had to fight to get mdframed working on Ubuntu, but it does exactly what I need. – eleybourn Jun 8 '12 at 3:26

The \llap command is your friend. It typesets the content passed as parameter "to the left" without changing the insert position.

\documentclass[a4paper,12pt]{article}
\usepackage{verbatim}
\usepackage{color}
\usepackage[english]{babel}
\usepackage{pifont}
\usepackage[strict]{changepage}
\usepackage{framed}
\usepackage{blindtext}

\newenvironment{tipbox}{%
\def\FrameCommand{%
{\llap{\Huge\ding{43}\hspace{1pt}}}
%
{\color{green}\vrule width 2pt}%
}%
\noindent\hspace{-4.55pt}% disable indenting first paragraph
\vspace{2pt}\vspace{2pt}%
}
{%
}

\begin{document}

\blindtext

\begin{tipbox}
You can expect your organisation to perform better, but only if everyone pointing in the same direction.
\end{tipbox}

\blindtext

\end{document}


• \llap is correct but you should start the environment with this command to get the dingbat at the top of the environment. – Marco Daniel Jun 6 '12 at 11:46

Solving a very similar problem I used the marginnote package. So (using the book class) it is possible to decide what is shown on the left and/or right page: \marginnote[left]{right}. Using the \scalebox command from the graphicx package one can mirror the symbol, so that an approach could be:

\documentclass[a4paper,12pt]{book}
\usepackage{verbatim}
\usepackage{color}
\usepackage[english]{babel}
\usepackage{pifont}
\usepackage[strict]{changepage}
\usepackage{framed}
\usepackage{blindtext}
\usepackage{marginnote}
\usepackage{graphicx}

\newenvironment{tipbox}{%
\def\FrameCommand{%
\hspace{1pt}%
{\color{green}\vrule width 2pt}%
}%
\MakeFramed{%
%
\marginnote[\Huge\ding{43}]{\scalebox{-1}[1]{\Huge\ding{43}}}%
%
\noindent\hspace{-4.55pt}% disable indenting first paragraph
\vspace{2pt}\vspace{2pt}%
}
{%
}

\begin{document}

\blindtext

\begin{tipbox}
You can expect your organisation to perform better, but only if everyone pointing in the same direction.
\end{tipbox}

\blindtext
\newpage
\begin{tipbox}
You can expect your organisation to perform better, but only if everyone pointing in the same direction.
\end{tipbox}
\end{document}


• I really like this approach (though for me I need it to be always on the left, so I'm using the above mdframed version). – eleybourn Jun 8 '12 at 3:27