4

I am making major edits (a hack and slash) to a big document, want to do a word count on what's there (hence texcount), and, while I'm editing and we are reviewing, I want to retain what I'm removing in situ in strikeout text.

The text has citations so in places these will need strikeouts also and I would like to be able to easily ultimately remove this text from the final document by a simple change of my commands and if the text is ignored I want to ignore any citations in the section so LaTeX does not look up by .bib files and add the citation to the bibliography. At the moment I am using makeboxes to try and format the strikeout but I am not getting the results I expect.

I am new to LaTeX so please excuse my poor code. There is more explanation in the code below. Thanks

%TC: macro \cmd [1]

\documentclass[]{article}
\immediate\write18{texcount.pl -total \jobname.tex -out=\jobname.sum}

\newcommand{\cmt}[1]{}
\usepackage{ulem}

\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{verbatim}
\newcommand\wordcount{\verbatiminput{\jobname.sum}}


% This is my command. I want to strike out, 
\newcommand{\strikeit}[1]
{
\makebox[\textwidth][s]{\sout{#1}}
}



\begin{document}
The first thing I want is to have this word count which ignores the words contained in the \textbackslash cmd macro
\wordcount

I want to be able to strike out text \sout{like this} and also be able to \sout{strikeout citations like this : \mbox{\cite{CA,HB98}}} and still have evertthing in situ but do all of this from a command that I can later edit to remove the edits from my pdf if they are all approved rather than manually editing the tex file twice.

Problem 1: This should be the width of the page and be in situ, but it's not \strikeit{\blindtext}

How do I wrap the text to the page (or text) width?

Problem 2: The next issue I am having is to do with citations.
\strikeit{
    \cite{CA,HB98} 
}

As you can see, the first citation is there, but the second is missing.
Also I'm getting the error \textit{Undefined Control Sequence. \}}

And Problem 3: When the edits are accepted I want to ultimatly be able to generate a PDF that will ignore these sections of text by changing my command \textit{\textbackslash strikeit} to

\textit{\textbackslash newcommand{\textbackslash strikeit}[1]{}}

but will also not process the citations if they are inside that command.

\begin{thebibliography}{1}

    \bibitem{HB98} Huynen, M.~A. and Bork, P. 1998. Measuring genome evolution. {\em
        Proceedings of the National Academy of Sciences USA}
    95:5849--5856.
    \bibitem{CA} Caprara, A. 1997. Sorting by reversals is difficult. In: {\em
        Proceedings of the First Annual International Conference on Computational
        Molecular Biology (RECOMB 97),} New York: ACM.  pp. 75-83.
\end{thebibliography} 
\end{document}
3
  • 1
    You can write \verb+\newcommand...+ if you want to show literal (La)TeX code in your document, instead of \textbackslash etc.
    – user31729
    Nov 5, 2015 at 12:49
  • \mbox{\cite{...}} will work.
    – user31729
    Nov 5, 2015 at 12:52
  • 1
    Maybe a versioning system (subversion, git) better suits your needs here? This looks like you try to recreate 'track changes' in MS Word / LibreOffice etc. which is not something that can be easily done in LaTeX.
    – Marijn
    Nov 5, 2015 at 13:36

1 Answer 1

3

This is no solution for the text wrapping in case of strikeout, but it removes the problem with \sout and \cite etc.

I've defined a \ifcorrectingmode switch and set it to true using \correctingmodetrue.

While this is active, \strikeit will show the effect of \sout. In the final run, just say \correctingmodefalse and \strikeit does nothing.

The \cite command isn't expandable, that's why \sout does not work, but it's possible to put \cite in box which is then stroke out.

%TC:macro \cmt [ignore]

\documentclass[]{article}
\immediate\write18{texcount -total \jobname.tex -out=\jobname.sum}

\usepackage{ulem}

\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{verbatim}

\usepackage{letltxmacro}
\newcommand{\cmt}[1]{}



\newcommand\wordcount{\verbatiminput{\jobname.sum}}

\newif\ifcorrectingmode
\correctingmodetrue

\LetLtxMacro\origcite\cite

% This is my command. I want to strike out, 
\newcommand{\strikeit}[1]{%
  \ifcorrectingmode
  \mbox{\sout{#1}}%
%  \makebox[\textwidth][s]{\sout{#1}}%
  \fi
}

\renewcommand{\cite}[2][]{%
  \ifcorrectingmode
  \mbox{\origcite[#1]{#2}}%
  \else
  \origcite[#1]{#2}%
  \fi
}

\begin{document}
The first thing I want is to have this word count which ignores the words contained in the \textbackslash cmd macro
\wordcount

I want to be able to strike out text \sout{like this} and also be able to \sout{strikeout citations like this : \mbox{\cite{CA,HB98}}} and still have evertthing in situ but do all of this from a command that I can later edit to remove the edits from my pdf if they are all approved rather than manually editing the tex file twice.

Problem 1: This should be the width of the page and be in situ, but it's not \strikeit{\blindtext}

How do I wrap the text to the page (or text) width?

Problem 2: The next issue I am having is to do with citations.
\strikeit{%
  \cite{CA,HB98}
}

As you can see, the first citation is there, but the second is missing.
Also I'm getting the error \textit{Undefined Control Sequence. \}}

And Problem 3: When the edits are accepted I want to ultimatly be able to generate a PDF that will ignore these sections of text by changing my command 
\verb+\strikeit+ to

\verb+\newcommand{\strikeit}[1]{}+

but will also not process the citations if they are inside that command.

\begin{thebibliography}{1}

    \bibitem{HB98} Huynen, M.~A. and Bork, P. 1998. Measuring genome evolution. {\em
        Proceedings of the National Academy of Sciences USA}
    95:5849--5856.
    \bibitem{CA} Caprara, A. 1997. Sorting by reversals is difficult. In: {\em
        Proceedings of the First Annual International Conference on Computational
        Molecular Biology (RECOMB 97),} New York: ACM.  pp. 75-83.
\end{thebibliography} 
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .