5

I'm using the comment package, in my preamble I have

\specialcomment{notes}{\begingroup \color{Blue}}{\endgroup}

so that when I want to comment my text I write

\begin{notes}...\end{notes}

to get a blue output. Because I need to print in black and white, it would be useful for the comments to be clearer in text. So I would like to get this to produce a line break, bold text saying "Notes:" and another line break at the end of my comment. I would also like to still be able to type

\excludecomment{notes}

to get rid of all my comments, without affecting the spacing of the text (as it would be without any notes).

Since I don't know anything about latex programming, I was hoping someone could help me, as experts on this site have been of great help to me in the past. Solutions that don't use the package I have at the moment would be fine as well. Thank you very much :)

1 Answer 1

5

Just define the notes environment to do what you want:

\documentclass{article}
\usepackage{xcolor,comment}

\newenvironment{notes}
 {\par\textcolor{blue}{\bfseries Note:} \color{blue}\ignorespaces}
 {\par}

%\excludecomment{notes}

\begin{document}

Some text for saying some nonsense.
\begin{notes}
Here we want to add a note.
\end{notes}
Start again with nonsense.

\bigskip

\excludecomment{notes}

Some text for saying some nonsense.
\begin{notes}
Here we want to add a note.
\end{notes}
Start again with nonsense.

\end{document}

Uncommenting the \excludecomment line will hide the notes environment, like in the emulation in the second part of the example.

enter image description here

The flow is interrupted, but this is a limitation of the comment package. When you are finished and remove the notes environments, you can reestablish the correct flow.

Note: I issued twice the color instruction, because it's better not to have \color after \par if it's possible to avoid it. However,

\newenvironment{notes}
 {\par\leavevmode\color{blue}{\bfseries Note:} \ignorespaces}
 {\par}

would be the same.

3
  • Yes, this is exactly what I wanted. Thanks a lot! Commented May 16, 2015 at 20:37
  • One last thing... I think I understand the issue about the flow being interrupted (so I will eventually have to manually get rid of all comments, correct?), but it would look a bit nicer if the paragraph after my notes wasn't indented. Please don't bother about this if it would entail a completely new solution, the one you wrote up in your answer is fine. Commented May 16, 2015 at 20:51
  • 1
    Use {\par\noindent\ignorespacesafterend} in the “final” part of the definition of the environment, instead of just {\par}.
    – egreg
    Commented May 16, 2015 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .