Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

up vote 6 down vote accepted

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

\documentclass{article}
\usepackage{xcolor}
\newcommand{\stefan}[1]{\textcolor{red}{#1}}
\newcommand{\supervisor}[1]{\textcolor{red}{#1}}

\begin{document}
Some text. \supervisor{Correct this!!}

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

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

% disable various comments
\renewcommand{\stefan}[1]{}

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:

\ifdefined\SupervisorMode
% re-define various commenting commands to do nothing
\renewcommand{\stephan}[1]{}
% ... etc., etc.
\fi

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

\usepackage{commentcommands}

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.

share|improve this answer
    
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. –  Peter Grill Nov 9 '12 at 19:21
    
@PeterGrill -- Very true. Your suggestion is a clear improvement, so I added it to the original answer. –  jon Nov 12 '12 at 9:46
add comment

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

Notes:

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

Code:

\documentclass{article}
\usepackage{xcolor}

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

\newcommand{\supervisor}[1]{}


\begin{document}
Some text. \stefan{Correct this!!}

\ifdefined\supervisor
    \renewcommand{\stefan}[1]{}
\fi

Some text. \stefan{Correct this also!!}
\end{document}
share|improve this answer
    
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 '12 at 9:49
    
Ok, but does the rest of the answer solve your issue? –  Peter Grill Nov 9 '12 at 9:53
add comment

You could use some boolean too.

For example:

\documentclass{article}

\makeatletter
\newif\if@supervisor 
\newcommand\stefan[1]{\if@supervisor\else#1\fi}
\newcommand\supervisor[1]{\if@supervisor#1\fi}

% toggle supervisor mode
\newcommand\supervisormode{\@supervisortrue}
\newcommand\notsupervisormode{\@supervisorfalse}
\notsupervisormode

\makeatother

\begin{document}

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

\end{document}
share|improve this answer
    
Welcome to TeX.sx! –  lockstep Nov 12 '12 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 '12 at 11:54
    
Thank you for the remark. I didn't plan to give minimal example. I have changed the source. –  Paul Pichaureau Nov 13 '12 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 '12 at 7:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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