# Setting a New Command (or is it an Environment?)

Here's a small example of what I have to use. I have to reset the length everytime I use `\marginnote` because it restarts indenting and reformats the skip to 0.

``````\marginnote{\normalsize Some text goes here}
\setlength{\parindent}{0in}
\setlength{\parskip}{0.15in}
``````

What I would like to be able to do is redefine this behaviour so I don't have to type so much junk (and keep my tex/Sweave document cleaner)

``````\somecommand Some text goes here
``````

Is there a way to get it to do so?

-
Why does `\marginnote` reset the lengths in the first place? –  Werner Mar 5 '12 at 18:23
No idea, and I don't understand latex enough to figure it out* –  Brandon Bertelsen Mar 5 '12 at 18:24
The grouping I suggest in my answer should work to keep the length modification to "within" `\somecommand`. –  Werner Mar 5 '12 at 18:25
That it does - thanks! –  Brandon Bertelsen Mar 5 '12 at 18:29

You could use a grouping structure to localise any changes made by `\marginnote`:

``````\newcommand{\somecommand}[1]{% \somecommand{<text>}
\begingroup
\marginnote{\normalsize #1}%
\endgroup
}
``````

You would then use

``````\somecommand{Some text goes here.}
``````
-
Perfect, I just added my \setlength's after \marginnote and it works as expected. –  Brandon Bertelsen Mar 5 '12 at 18:29