Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\reversemarginpar
\chapter{Getting started}
\pagestyle{headings}
AABBB
\marginpar{\includegraphics[scale=0.3]{images/example}}

CCC

gives:

enter image description here

I get similar results with \marginnote

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

share|improve this question
    
E.g. with \marginpar (LaTeX-kernel) or \marginnote (from the marginnote package). –  Ulrike Fischer Dec 17 '12 at 9:31
    
@UlrikeFischer: Hmm, \marginpar doesn't work (see above). I'll try \marginnote –  Manishearth Dec 17 '12 at 9:50
    
As seen in the first answer, this is more a problem of a page geometry than of a LaTeX solution. Because naturally, in a book, the inner margin is really small to contain any such material. However, if you use these "exclamation marks" often, you can make the inner margin wider, it wouldn't be that much a typographical crime ;) –  tohecz Dec 17 '12 at 10:33
1  
\marginpar does work. But your page layout is not adapted for large objects on the inner margin. You can use hfill to move the picture on odd pages \marginpar[{\hfill\includegraphics[scale=0.3]{example}}]{\includegraphics[scale‌​=0.3]{example}}. But if you want the pictures always on the left side, you should check this answer: tex.stackexchange.com/questions/62017/… –  Ulrike Fischer Dec 17 '12 at 10:33
add comment

2 Answers

up vote 7 down vote accepted

Try a right-justified paragraph:

\marginpar{\hfill\includegraphics[scale=0.3]{images/example}}

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

\marginpar{\includegraphics[scale=0.3]{images/example}\hfill}

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:

\marginpar{\hfill\includegraphics[width=\marginparwidth]{images/example}}

or use a fraction:

\marginpar{\hfill\includegraphics[width=0.95\marginparwidth]{images/example}}
share|improve this answer
1  
This won't help with \reversemarginpar. \marginparwidth is larger than the left (inner) margin on odd pages. –  Ulrike Fischer Dec 17 '12 at 10:25
    
Adding the appropriate \hfill worked for me. –  lhf Dec 17 '12 at 10:29
    
Thanks, this works now :) –  Manishearth Dec 17 '12 at 10:37
3  
You should use the optional argument for odd/even pages. –  Ulrike Fischer Dec 17 '12 at 10:38
    
@UlrikeFischer, thanks, I've edited my answer. –  lhf Dec 17 '12 at 10:41
add comment

You can also try TikZ in 'overlay mode'. Maybe not elegant, but it works ;-)

\documentclass[12pt]{article} 
\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{tikz}
\usetikzlibrary{shapes}

\newcommand{\keyPointR}{
\begin{tikzpicture}[overlay]
  \node[draw, rectangle] at (13,0) {KeyPoint R};
\end{tikzpicture}
}

\newcommand{\keyPointL}{
\begin{tikzpicture}[overlay]
  \node[draw, rectangle] at (-8.5,0) {KeyPoint L};
\end{tikzpicture}
}

\begin{document}
\blindtext
\keyPointR

\blindtext[2]
\keyPointL

\blindtext
\end{document}`
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.