# texdiff on plain tex files

I have two TeX files that I need to compare, and I thought texdiff could do this for me. Unfortunately, in the manual page, it reads

For texdiff to work, the following LaTeX code must be inserted in the preamble of the LaTeX document:

\usepackage{xcolor} \usepackage{ulem} \usepackage{changebar}
\newcommand\TLSins[1]{\cbstart{}\textcolor{ins}{\uline{#1}}\cbend{}}
\newcommand\TLSdel[1]{\cbdelete{}\textcolor{del}{\sout{#1}}}


Now, I'm a bit lost as I have never actually used plain TeX and using LaTeX code inside a TeX file is obviously not going to work.

## Example:

Let's consider a very simple plain TeX example. If you use a file with the following content:

Let $D$ be a subset of $\bf R$ and let $f \colon D \to {\bf R}$ be a real-valued function on $D$. The function $f$ is said to be
{\it continuous} on $D$ if, for all $\epsilon > 0$ and for all $x \in D$,
there exists some $\delta > 0$ (which may depend on $x$) such that if $y \in D$ satisfies $$|y - x| < \delta$$ then $$|f(y) - f(x)| < \epsilon.$$

\bye


With pdftex file.tex this can easily be converted to

Now, if you make a change in the file and store it under a different name, you can run

texdiff file1.tex file2.tex diff.tex


you will have the following content inside diff.tex

Let $D$ be a subset of $\bf R$ and let $f \colon D \to {\bf R}$ be a real-valued function on $D$. The function $f$ is said to be
{\it continuous} on $D$ if, for all $\epsilon > 0$ and for all $x \in D$,
there exists some $\delta > 0$ \protect\TLSins{(which may depend on $x$)} such that if $y \in D$ satisfies $$|y - x| < \delta$$ then $$|f(y) - f(x)| < \protect\TLSdel{\epsilon$$ should hold.}
\protect\TLSins{\epsilon.}

\bye


The commands \TLSins and TLSdel don't exist in plain TeX, and I cannot only put \usepackage and \newcommand inside this file. This would not work.

Question: How must the header look like to define the required commands correctly in plain TeX?

• Is this helpful? Dec 4, 2016 at 7:13
• Unfortunately not. The problem is that I have plain tex files. I too used latexdiff successfully on LaTeX documents and since I found it so helpful, I want to use it on plain tex documents a colleague sent me. Dec 4, 2016 at 7:33
• I have never tried this but as far as I can see Latexdiff should work on plain tex files too.
– user30471
Dec 4, 2016 at 10:19
• @Andrew I have extended my question to show exactly that the problem is not texdiff itself, but the output it creates, because, in the resulting diff, there are LaTeX commands while I need to use TeX to compile the file. Dec 4, 2016 at 14:39
• Thanks. I understand your problem now (sorry for being slow!)
– user30471
Dec 4, 2016 at 19:45

The changebar and ulem packages do not seem to have plain TeX equivalents but for colour you can just \input color. With some care (using \ifmmode...\fi etc), you could get by using {\em ...} and \underline{...} in place of ulem (changebar would be harder).

The simplest way to get texdiff to work is to add the following code to the top of your diff file:

\input color
\def\TLSins#1{{\color{blue}#1}}
\def\TLSdel#1{{\color{red}#1}}


This does not add emphasis or underlining for the differences, and there are no change-bars, but it does it does show where the changes are:

Of course, this will be subject to the usual vagaries of (la)texdiff.

• Good answer, but the package is ulem not uelm. Spelling the package name correctly seems worthwhile and worth correcting in your answer so readers are not misinformed. Dec 5, 2016 at 5:21