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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have tried to play with a MWE from @cmhughes in this topic, and discovered that words inside \marginpar do not wrap like they should. Here is a MWE:

\documentclass[12pt,openany,oneside,a4paper]{report}
\usepackage{tikz}                       
\usepackage{lipsum}

\let\oldmarginpar\marginpar
\renewcommand{\marginpar}[2][rectangle,draw,fill=black, text=white ,rounded corners]{
    \oldmarginpar{
    \scriptsize \tikz \node at (0,0) [#1]{#2};}
    }

\begin{document}
\lipsum[1]
\marginpar{margin text here, but it doesnt wrap like it should!!!}

\lipsum[2]
\end{document}

I also discovered that if I put for example $$m = 0$$ inside \marginpar{} it wont go into a new line like it should.

share|improve this question
up vote 5 down vote accepted

Use text width in the option for node. (I used text width= 2cm, here which you can change for your requirement.)

\documentclass[12pt,openany,oneside,a4paper]{report}
\usepackage{tikz}
\usepackage{lipsum}

\let\oldmarginpar\marginpar
\renewcommand{\marginpar}[2][rectangle,draw,fill=black, text=white,text width= 2cm,rounded corners]{
    \oldmarginpar{
    \scriptsize \tikz \node at (0,0) [#1]{#2};}
    }

\begin{document}
\lipsum[1]
\marginpar{margin text here, but it doesnt wrap like it should!!!}

\lipsum[2]
\end{document}

enter image description here

share|improve this answer

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.