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.

In a .tex file, there is some self defined command

\newcommand{\mycomment}[1]{\textcolor{red}{#1}}
...
\mycomment{blah blah}
...

I hope to be able to skip the command during compilation in my final version, but still compile it in versions before my final version. Are there any ways to do that?

share|improve this question
1  
do you just mean change to \newcommand{\mycomment}[1]{} for the final version? Or something else? –  David Carlisle Apr 14 '13 at 23:16
    
@David: In the final version, \mycomment{blah blah} will be ignored during compilation. –  Tim Apr 14 '13 at 23:22
1  
The definition I suggested in the first comment does that, it defines the command to take the argument and do nothing with it –  David Carlisle Apr 14 '13 at 23:25

2 Answers 2

Another fairly intuitive method, particularly if you have several large blocks of code which you want to include in some compilations but not others is the comment package (also saves a lot of time if you are writing a very large manuscript, but only working on a small bit at a time). However its great for small toggles too.

\usepackage{comment}
 %switches    
\excludecomment{versiona}
\excludecomment{versionb}
\includecomment{versionx}

..

\begin{versiona}
\newcommand{\mycomment}[1]{\textcolor{red}{#1}
etc
\end{versiona}

\begin{versionb}
\newcommand{\mycomment}[1]{\textcolor{red}{#1}
etc
\end{versionb}
share|improve this answer
\newif\iffinal
\newcommand{\mycomment}[1]{\iffinal\else\textcolor{red}{#1}\fi}
...
\mycomment{blah blah}

And you have Boolean values \finaltrue and \finalfalse. For development versions set \finalfalse somewhere in the preamble after \newif\iffinal, for the final compilation set \finaltrue, or set both and comment out the inactive Boolean:

\finalfalse
% \finaltrue
share|improve this answer
1  
BTW I find the bools or toggles from etoolbox much more convenient. –  Speravir Apr 14 '13 at 23:39

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.