How to write “note:” in front of an indented paragraph

I have a question similar to this one:

How to mark book paragraphs as note, warning, tip etc.?

I'd like to have my paragraph indented and the text "note:" appear just before it. Ideally this would be a kind of macro that I could reuse anywhere in my text.

The rendered text should be similar to this:

Duis porttitor nisi et orci pellentesque feugiat. Aenean id
turpis vel purus tincidunt sodales. Class aptent taciti
sociosqu ad litora torquent per conubia nostra, per inceptos
himenaeos. Cras semper dui et nulla feugiat at convallis dolor
tincidunt. Lorem ipsum dolor sit amet, consectetur adipiscing
elit.

Note:  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aenean et erat quis turpis tristique ultricies at in est.
Nunc quis volutpat neque. Nunc sit amet turpis nec risus
vehicula tristique ac ac risus. Cras interdum vehicula
metus. Nulla facilisi. Duis faucibus porttitor elit
mattis venenatis.


By the way, I'm using the "book" documentclass.

-

You can use the package enumitem and define a list that you can use for notes such as the following:

\documentclass{article}

\usepackage{enumitem}

\newlist{notes}{enumerate}{1}
\setlist[notes]{label=Note: ,leftmargin=*}

\begin{document}

Duis porttitor nisi et orci pellentesque feugiat. Aenean id turpis vel
purus tincidunt sodales. Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos himenaeos. Cras semper dui
et nulla feugiat at convallis dolor tincidunt. Lorem ipsum dolor sit
\begin{notes}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Aenean
et erat quis turpis tristique ultricies at in est.  Nunc quis
volutpat neque. Nunc sit amet turpis nec risus vehicula tristique ac
ac risus. Cras interdum vehicula metus. Nulla facilisi. Duis
faucibus porttitor elit mattis venenatis.
\end{notes}

\end{document}


By using enumitem and defining the note as an enumeration it will be easy to make it so that every note gets numbered if you want that. You simply change the setlist macro to

\setlist[notes]{label=Note \arabic*:, resume, leftmargin=*}


and this way notes will be numbered as "Note 1:", "Note 2:", "Note 3:", etc.

Finally, if you find the syntax

\begin{notes}
\item Lorem ipsum
\end{notes}


stupid since you will never include more than one \item you can define a macro that includes the \item

\newenvironment{note}[1]{\begin{notes}\item #1}{\end{notes}}


so that you instead make notes with

\begin{note}
Lorem ipsum
\end{note}

-
Yes, it renders exactly what I expect! Thanks a lot! –  ogregoire Jan 17 '12 at 15:30
@ogregoire Good to hear. I have updated my answer to include alternatives. –  N.N. Jan 17 '12 at 15:43
Great additions, so I don't have to write \item everywhere! –  ogregoire Jan 17 '12 at 15:56

The primitive TeX command hangindent can be used for this purpose.

\documentclass{article}
\parindent0pt

\begin{document}
Duis porttitor nisi et orci pellentesque feugiat. Aenean id
turpis vel purus tincidunt sodales. Class aptent taciti
sociosqu ad litora torquent per conubia nostra, per inceptos
himenaeos. Cras semper dui et nulla feugiat at convallis dolor
tincidunt. Lorem ipsum dolor sit amet, consectetur adipiscing
elit.

\hangindent3em
Note:  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aenean et erat quis turpis tristique ultricies at in est.
Nunc quis volutpat neque. Nunc sit amet turpis nec risus
vehicula tristique ac ac risus. Cras interdum vehicula
metus. Nulla facilisi. Duis faucibus porttitor elit
mattis venenatis.

\end{document}


You can also define a command to handle it more semantically either with LaTeX or TeX,

\long\def\note#1\par{%
\leavevmode
\hangindent3em Note: #1}


You can then use it as follows:

\note
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aenean et erat quis turpis tristique ultricies at in est.
Nunc quis volutpat neque. Nunc sit amet turpis nec risus
vehicula tristique ac ac risus. Cras interdum vehicula
metus. Nulla facilisi. Duis faucibus porttitor elit
mattis venenatis.


No need to be enclosed in brackets, as long as you leave a line at the end to ensure that there is a paragraph end.

-
This seems to render improperly when I have several paragraphs in my note. But it's nice to see anyone else helping :) Also, the "Lorem" and the next line's "Aenean" will not be properly aligned. –  ogregoire Jan 17 '12 at 15:34
@ogreigoire The alignment works for me. This can only be used for one paragraph, as stated in the question. It is always good to know how TeX typesets. Adding for example \hangafter will affect the number of lines being indented. For multiple paragraphs one has to use \everypar and the code is somewhat longer. –  Yiannis Lazarides Jan 17 '12 at 15:43
if there's more than one paragraph, the first could be "ended" with \newline and a suitable \hspace* added at the beginning of the next line. latex wouldn't detect this as a paragraph, so the indentation wouldn't be lost. (of course, using enumitem is more elegant, and wouldn't give rise to possible "widows" or "orphans" in case of an unfortunately placed page break.) –  barbara beeton Jan 17 '12 at 16:00
@egregoire If you remove the \parindent0pt it will render the same. Don't worry about the +1, if you didn't find the answer useful you don't have to upvote. This is what the voting system is all about. –  Yiannis Lazarides Jan 17 '12 at 16:08
@Yiannis -- the problem with uneven indentation can be fixed by a slight change in the definition: \long\def\note#1\par{\leavevmode \hangindent3em \hbox to 3em{Note:\hss}\ignorespaces#1}. for a subsequent paragraph, one could define a similar \phantomnote with the box containing just \hfil. –  barbara beeton Jan 17 '12 at 20:31