I have defined some custom commands that I use for TODO-notes. If I write a note i use the command \stefan{}.

Now I want to define a new command, for example \supervisor{}.

I need a way to get LaTeX to ignore either one of the commands. When \supervisor is disabled I will want the \stefan command to get compiled.

Is this even possible?

3 Answers 3


You could do this from the command line. Take @PeterGrill's basic document:


Some text. \supervisor{Correct this!!}

Some text. \stefan{Correct this also!!}

This will give you all the comments. Then create a .sty file, which could be as simple as:

% disable various comments

Then, when you want to 'hide' various comments, compile from the command line:

pdflatex "\AtBeginDocument{\input{mycomments.sty}}\input{masterfile.tex}" 

Or compile normally when you want all comments to appear.

Or, perhaps even more elegantly, you could implement @PeterGrill's suggestion:

Use the following (say) file commentcommands.sty:

% re-define various commenting commands to do nothing
% ... etc., etc.

Then load commentcommands.sty after the original comment commands in the master file:


Then, when you want to 'disable' the various commands in the document you hand to your supervisor, run the command as:

pdflatex "\def\Supervisormode{}\input{masterfile.tex}"

This does have the advantage of a clearer call to pdflatex, which you could also put into a makefile if you were so inclined.

  • Excellent idea. A slight implement would be to use \ifdefined\SupervisorMode \renewcommand{\stefan}[1]{} \fi in the .sty file and then use def\SupervisorMode{} on the command line. Same idea, but you don't need two files, and the command line is more readable. Nov 9, 2012 at 19:21
  • @PeterGrill -- Very true. Your suggestion is a clear improvement, so I added it to the original answer.
    – jon
    Nov 12, 2012 at 9:46

If I understand you correctly, one way would be to use \ifdefined\supervisor to test if \supervisor was defined, and if so redefine the \stefan macro:

enter image description here


  • If you are using the todonotes package, you can use \usepackage[disable]{todonotes}



\newcommand{\stefan}[1]{\textcolor{red}{Stefan's Comment: #1}}


Some text. \stefan{Correct this!!}


Some text. \stefan{Correct this also!!}
  • Thank you for your suggestion. Yes, I am using the todonotes package. The problem with the disable option, is that it will disable every todonote in the document. I am working in a team on a project where we have a superviser assigned. Each member of the team have their own \name command to write a todo note. Whenever we want to turn in our document for comments by our supervisor, we do not want our todo notes to be visible. So we need a way to disable our own notes where we will still be able to write a note for our supervisor. I hope it makes a little more sense with my explanation.
    – thilemann
    Nov 9, 2012 at 9:49
  • Ok, but does the rest of the answer solve your issue? Nov 9, 2012 at 9:53

You could use some boolean too.

For example:



% toggle supervisor mode



  \stefan{This is stefan comment}
  \supervisor{This is supervisor comment}

  • Welcome to TeX.sx!
    – lockstep
    Nov 12, 2012 at 10:47
  • The code seems faulty: the @-commands should be enclosed between \makeatletter and \makeatother; a couple of \newcommand are missing.
    – egreg
    Nov 12, 2012 at 11:54
  • Thank you for the remark. I didn't plan to give minimal example. I have changed the source. Nov 13, 2012 at 7:33
  • 1
    Having a complete example is surely better, if feasible. The problem with @ is recurrent, because people not acquainted with LaTeX programming may not be aware that \makeatletter and \makeatother are necessary.
    – egreg
    Nov 13, 2012 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.