1

I want to revise my paper so some sentences must be Deleted/Added/Revised. I need two versions of the manuscript:

  • with Deleted sentences,
  • without Deleted sentences.

I used the template presented in the question: Ignoring all but certain text

However, I have some problems:

  1. When I use \‎let\ignoreflag\relax‎‎‎ and compile my code (based on xelatex), the distances between three different types of sentences are omitted.

Image 1

  1. and when I omit using \‎let\ignoreflag\relax‎‎‎, I get the following error:

    "! Argument of \xignore has an extra }. \par"

and again, the distances between two different types of sentences are omitted.

Image 2

\documentclass{article}
\long\def\dontignore#1{#1}
\makeatletter
\long\def\ignoreflag{\@makeother\{\@makeother\}\xignore}
\long\def\xignore#1\dontignore#2{\catcode`\{\@ne\catcode`\}\tw@\afterassignment\xxdontignore\toks@\bgroup}
\long\def\xxdontignore{\the\toks@\ignoreflag}
\makeatother
\usepackage[dvipsnames]{xcolor}
\usepackage[normalem]{ulem}
\newcommand{\mydelete}[1]{\color{red}{\ignoreflag\sout{#1}}\color{black}}
\newcommand{\myadd}[1]{\textcolor{blue}{#1}\color{black}}
\newcommand{\need}[1]{\textsc{\textcolor{Maroon}{#1}}}
\let\ignoreflag\relax
\begin{document}
\dontignore
This is some text: \mydelete{I want to IGNORE this text OR TAKE IT INTO ACCOUNT} \myadd{I want to ADD this text} \need{I want to REVISE this text.}
\end{document}
Vahid
  • 109

2 Answers2

3

I do not know what all that \ignoreflag stuff is trying to accomplish, but couldn't you approach it more simply?

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[normalem]{ulem}
\newcommand{\ORIGmydelete}[1]{\textcolor{red}{‎‎‎‎\sout{#1}}}
\newcommand{\myadd}[1]{\textcolor{blue}{#1}}
\newcommand{\need}[1]{\textsc{\textcolor{Maroon}{#1}}}
\newcommand\ignore{\renewcommand\mydelete[1]{\ignorespaces}}
\newcommand\dontignore{\let\mydelete\ORIGmydelete}
\dontignore
\begin{document}‎     ‎ ‎
This is some text:‎ ‎\mydelete{I want to IGNORE this text OR TAKE IT INTO ACCOUNT} ‎‎\myadd{I want to ADD this text}‎ ‎\need{I want to REVISE this text.}

\ignore
This is some text:‎ ‎\mydelete{I want to IGNORE this text OR TAKE IT INTO ACCOUNT} ‎‎\myadd{I want to ADD this text}‎ ‎\need{I want to REVISE this text.}
\end{document}

enter image description here

1

The solution you are referring to provides a way of hiding (or not hiding) all text that is not included in a \dontignore. Since you only want to hide a small portion of your text, you would need to include all the text you write in \dontignore commands except for the \mydelete parts.

So instead of using that solution, I would suggest to do something much easier, like this:

\usepackage{etoolbox}
\newtoggle{ignoreflag}
\newcommand{\mydelete}[1]{\iftoggle{ignoreflag}{}{#1}}
\toggletrue{ignoreflag} %don't print the text
\togglefalse{ignoreflag} %print the text

(or the way it is done in Steven's answer). Since only \mydelete shall be effective, you only need to have a short switch inside the \mydelete definition to either print something or not. (This part is inspired by this answer.)

To your other question: Spaces after your macros are ignored. You can manually change this by adding another {} after each macro, or adding an explicit space \. Since this is rather cumbersome, you can use the xspace package like this:

\usepackage{xspace}
\newcommand{\myadd}[1]{#1\xspace}

which automatically detects whether a space needs to be added after the macro or not. There are, however, several people who advise not to use xspace, so read their arguments before deciding to do so.

Full example:

\documentclass{article}
\usepackage{xspace}
\usepackage[dvipsnames]{xcolor}
\usepackage[normalem]{ulem}
\usepackage{etoolbox}

\newtoggle{ignoreflag}
\newcommand{\mydelete}[1]{\iftoggle{ignoreflag}{}{\color{red}{\sout{#1}}\color{black}\xspace}}
\newcommand{\myadd}[1]{\textcolor{blue}{#1}\color{black}\xspace}
\newcommand{\need}[1]{\textsc{\textcolor{Maroon}{#1}}\xspace}

\begin{document}

\toggletrue{ignoreflag}
This is some text: \mydelete{I want to IGNORE this text OR TAKE IT INTO ACCOUNT} \myadd{I want to ADD this text} \need{I want to REVISE this text.}

\vspace{\baselineskip}

\togglefalse{ignoreflag}
This is some text: \mydelete{I want to IGNORE this text OR TAKE IT INTO ACCOUNT} \myadd{I want to ADD this text} \need{I want to REVISE this text.}

\end{document}

enter image description here

Tiuri
  • 7,749