In a LaTeX document I'm writing, I'm using the Comment package to write personal notes that I can enable and disable at will, as in the next example:

% Uncomment the next line for public version without personal notes


This is a serious sentence.

This is a personal note


Then by toggling between \excludecomment{note} and %\excludecomment{note} in the preamble, I can choose whether the document includes my personal notes or not. So far, so good.

Now comes my question: how can I do something similar with inline text within a paragraph? I would like to do something like the following:

This is a serious \note{(or not??)} sentence.

But of course that doesn't work as "note" has been defined as an environment through the \specialcomment command. So, is there any way I can use the Comment package to do this? Or some other solution?

1 Answer 1


For example:



With the usage \mynote{This ia a note}. And if you want to hide your notes, you write \mynotesfalse.

  • 1
    you might want to add an \ignorespaces between \else and \fi. Otherwise, you will have two spaces with \mynotesfalse.
    – jakun
    Commented Sep 21, 2017 at 10:04
  • This rocks, thanks! There's only a minor problem left, which I haven't been able to fix with @jakun's \ignorespaces. What if I have the inline comment in front of a punctutation mark, like This is a serious sentence\note{ (or not??)}.? Ideally, I'd like it to appear as either "This is a serious sentence." or "This is a serious sentence (or not??)." But I'm finding it tricky to get the space before the parenthesis when notes are enabled. Commented Sep 21, 2017 at 12:39
  • @ÁngelJoséRiesgo replace \ignorespaces with \unskip. \ignorespaces eats up following spaces, \unskip eats up preceding spaces. (At first I thought it wouldn't matter which one to use here, but it seems I did not think far enough. Good point.)
    – jakun
    Commented Sep 22, 2017 at 9:16
  • Thanks, @jakun. That's great; it now works perfectly. I can now write 'This is a serious sentence \note{(or not??)}.' and the whitespace after "sentence" vanishes when disabling the notes. Commented Sep 22, 2017 at 11:52

You must log in to answer this question.

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