# New command doesn't work the same as in-line code

I have a feeling that this is a profoundly stupid question but I cannot seem to solve it myself.

I am trying to write an own macro to create a boxed paragraph. The code works fine in-line but when I try to define the command it just creates a small box in the same place that I wrote the command. My codes are below. I am pretty much a complete newbie at this and any help would be greatly appreciated.

\fbox{\parbox{\linewidth}{Inline this works perfectly.}}

\newcommand{\note}{\fbox{\parbox{\linewidth}{}}}

-
Welcome to TeX.sx! –  Torbjørn T. Jan 5 '13 at 16:06

In

\newcommand{\note}{\fbox{\parbox{\linewidth}{}}}


The content of the parbox is always specified by {} so empty.

\note{hello}


will make an empty box from \note before seeing hello.

You want hello to be an argument of \note so

\newcommand{\note}[1]{\fbox{\parbox{\linewidth}{#1}}}

-
And that's called a quick response! -- At the velocity of light! :-) –  Harish Kumar Jan 5 '13 at 16:10
Thanks a lot, that works beautifully. Much appreciated! –  Mara Jade Jan 5 '13 at 16:22
@MaraJade \newcommand{\note}[1]{\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule\rel‌​ax}{#1}}} is probably better. I’d throw in an additional \noindent too. –  Qrrbrbirlbel Jan 5 '13 at 18:17
Yes do as @Qrrbrbirlbel says, I addressed the programming question about how to define a macro with arguments but \newcommand{\note}[1]{\noindent\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fbo‌​xrule\rel‌​ax}{#1}}} is a better definition in this case as otherwise the box will not fit on the line as the inner box is already full width and then outer box has padding and a rule on either side, and TeX may add paragraph indentation at the start. –  David Carlisle Jan 5 '13 at 18:30