0

I've created a very simple environment for myself to make reminders/comments visible inside the document:

\newenvironment{todo}{~\\\color{red}}{~\\}

However, now I want to create a pdf for someone to proof-read and want to omit all those ToDos from the pdf. Is there a way to simply hide all the ToDos from the document by changing the environment-definition? Or maybe replace the content inside the todos with something simple like

<TODO>
1
  • Redefine your environment as being the same as comment in a copy of your .tex file. You may also see the xcomment package.
    – Bernard
    Nov 3 '20 at 11:00
2

Here are two options:

  1. You can use the comment package and do \excludecomment{todo}, but this will insert a line break between the text before and after the environment:

enter image description here

  1. You can use xparse and redefine the environment to grab its contents with +b and throw them away, then you have no line break:

enter image description here

Also, adding \ignorespacesafterend will avoid one spurious spaces after the \end{todo}.

\documentclass{article}
\usepackage{color}

\newenvironment{todo}{~\\\color{red}}{~\\\ignorespacesafterend}

% % Option 1:
% \usepackage{comment}
% \excludecomment{todo}

% Option 2:
\usepackage{xparse}
\RenewDocumentEnvironment{todo}{+b}{}{\ignorespacesafterend}

\begin{document}

some text
\begin{todo}
  lotsa
\end{todo}
some text

\end{document}
1
  • Thank you. I just added a '//todo' inside the empty curly brackets to just print out that word - to indicate that position in the text.
    – RazorHail
    Nov 3 '20 at 12:07

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.