[Tex/LaTex] How to add side-icons in a LaTeX book


Most of the technical books I've read use what I call "side icons" to mark out certain types of content. Stuff like "watch out for this" and "helpful tip", with corresponding icons.

Here's an example of what I mean (the "key point" and "coding horror" icons):

enter image description here

Taken from http://www.codinghorror.com/blog/2007/12/on-the-meaning-of-coding-horror.html

How can I do this in LaTeX (with \documentclass{book})? To be clear, I want to be able to attach icons (with captions) to text so that the icons are outside the normal flow of the text.

I have tried \marginpar (reversed), it's always pushing a portion of the image out of the paper. For example, the following code:

\chapter{Getting started}



enter image description here

I get similar results with \marginnote

using http://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg.

Best Answer

Try a right-justified paragraph:


On even-numbered pages, you need a left-justified paragraph:


This can be simplified by using the optional argument for odd/even pages. It is convenient to encapsulate all this magic in a macro.

You may also need to adjust the size of the images to the width of the margin par:


or use a fraction:

Related Question