20

I am writing a document with extra notes intended only for myself.

\newcommand{\mycomment}[1]{\emph{Note: #1}}
%\newcommand{\mycomment}[1]{}

When I wish to remove the extra comments, I simply comment the first line and uncomment the latter line. Then each call to \mycomment should do nothing. However, instead each call generates a small space. Is it possible to remove this space?

Many thanks.

user82371
  • 203
  • Just add \renewcommand{\mycomment}[1]{\null} if you want to remove these. – Martin - マーチン Jul 18 '13 at 15:51
  • Perhaps, depending on how you use it, %\newcommand{\mycomment}[1]{\unskip} – Steven B. Segletes Jul 18 '13 at 15:53
  • Thank you! \null will reduce the space, but there will be a noticeable space after multiple calls. \unskip works with the same effect as \ignorespaces (no space even after multiple calls). – user82371 Jul 18 '13 at 16:04
  • re difference between \ignorespaces and \unskip. The former seems indeed to be safer; In some locations, \unskip can generate an "ERROR: You can't use \unskip in vertical mode.", but \ignorespaces will work fine. – user82371 Jul 18 '13 at 16:19

1 Answers1

20

Safest is probably

\newcommand{\mycomment}[1]{\ignorespaces}
David Carlisle
  • 757,742
  • Thank you! This creates no space even for multiple calls. – user82371 Jul 18 '13 at 16:00
  • 1
    Note that the command never creates space. The question is about removing space that the author has added to the document. that is with the empty definition in the question, xx\mycomment{zz}yy has no space but if the author adds space xx \mycomment{zz} yy then there are two spaces, but this definition makes the second be ignored (\unskip as discussed in the comments tries to remove the first but should be guarded by a test that the space is there) – David Carlisle Jun 04 '20 at 10:03