# Words don't wrap inside redefined \marginpar{}

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.

-

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}


-