Alignment of marginnote independently of main paragraph

I've noticed that when a \marginnote is added (edit: using the marginnote package), the horizontal alignment of that note is inherited from wherever the note is placed. In my case, I wish to have a margin note defined inside a section heading, which makes the margin note centred.

If I try to add \raggedleft or \raggedright to the instruction, then it is either ignored, or overwrites the formatting of the section header (depending on whether it is in the left or right margin).

Is there some way to change the horizontal alignment of the marginal text independently of the text in which it is defined?

Edit: My apologies, in constructing the minimum working example, I realise I've embarrassingly omitted the important detail of how I (almost certainly incorrectly) set the centering of the section header. Below is a minimum working example of what I want.

\documentclass{article}
\RequirePackage{sectsty}
\allsectionsfont{\centering\sc} % <-- this is probably wrong!

\begin{document}
\section*{This is a section header\marginnote{I really really want this
margin note to be raggedright, and not centred like it is here.}}
\end{document}


Another point to note is that I actually want the text flushed left or right depending on whether the note is in the left or the right margin. This means is think I do need to change the alignment of the marginal text.

-
You need to provide a small example document that demonstrates the effect you describe (which is not the expected behaviour) – David Carlisle May 11 '14 at 20:36

I assume (but you don;t say) that you are using \marginnote from the marginnote package. That like a standard \marginpar does not pick up the current alignment. The following shows the note is justified as normal whether it is used in a justified paragraph, or a flushleft or centred one.

\documentclass{article}

\usepackage{marginnote}

\begin{document}

one two three one two three one two three one two three one two three one two three%
\marginnote{a a a a a a a a a a}
one two three one two three one two three one two three one two three one two three

\begin{flushleft}
one two three one two three one two three one two three one two three one two three%
\marginnote{a a a a a a a a a a}
one two three one two three one two three one two three one two three one two three
\end{flushleft}

\begin{center}
one two three one two three one two three one two three one two three one two three%
\marginnote{a a a a a a a a a a}
one two three one two three one two three one two three one two three one two three
\end{center}

\end{document}


sectsty is doing somethig odd, can't be bothered to debug that so just re-assert the normalisation of font and alignment that marginpar/marginnote do anyway but that got broken somewhere. This is ragged left on one side and raggedright in the other, as is normal for marginnote.

\documentclass[twoside]{article}
\RequirePackage{sectsty}
\allsectionsfont{\centering\sc} % <-- this is probably wrong!

\makeatletter
\renewcommand\marginfont{\normalfont}
\renewcommand\raggedleftmarginnote{\@parboxrestore\@marginparreset\raggedleft}
\renewcommand\raggedrightmarginnote{\@parboxrestore\@marginparreset\raggedright}
\makeatother

\begin{document}

\section*{This is a section header\marginnote{I really really want this
margin note to be raggedright, and not centred like it is here.}}

\clearpage

\section*{This is a section header\marginnote{I really really want this
margin note to be raggedright, and not centred like it is here.}}

\end{document}

-
This is really helpful, but unfortunately my incompetence breaks it. Perhaps in light of my edit, you have a better idea... – Henry Gomersall May 11 '14 at 21:08
@HenryGomersall see update – David Carlisle May 11 '14 at 21:43
It works perfectly - thanks! – Henry Gomersall May 11 '14 at 22:04