I just started trying out latexdiff for editing some papers and I am having trouble with the getting the tex output from latexdiff compile when my code includes \intertext within a \begin{align*} environment. This is the error I get

Underfull \hbox (badness 10000) in paragraph at lines 83--86

/Users/erikchan/Desktop/TSWLatexianTemp_000048.tex:131: Misplaced alignment tab character &.
\math@cr@@@ ->&
               \omit \global \advance \row@ \@ne \ifst@rred \nonumber \fi \if@eqnsw \global \tag@true \fi \ifnum \column@ >\maxfields@ \ifcheckat@ \begingroup \measuring@false \@amsmath@err {Extra & on this line}{\the \andhelp@ }\endgroup \else \global...
l.131      }\end{align*}


The version of latexdiff I am running is

This is LATEXDIFF 1.0.3  (Algorithm::Diff 1.1902, Perl v5.12.4).

Thank you in advance.

Edit: I should add that I made several attempts to find a solution to this, but I couldn't find an existing solution online and this error completely mystifies me because I don't understand why it is complaining about my alignment tab.

Edit2: I tried to look for the error and I still cannot find it. If it is a syntax error, is it common for latexDiff to output code with syntax errors?

%DIF DEL Lecture.tex     Tue Dec 10 18:18:33 2013
%DIF ADD Lecture 2.tex   Tue Dec 10 18:17:11 2013
\newcommand{\bs}{\\ $\left.\right.\hfill\blacksquare$}
\newcommand{\pf}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\pfn}[3]{\frac{\partial^{#3} #1}{\partial {#2}^{#3}}}

% unnumbered environments:

\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF     PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE


\title{Wavelets and Signal Processing}
A wavelet is just a small portion of a larger signal. We wish to express the signal as the     sum of waves, so given a signal \DIFdelbegin \DIFdel{$\vec f$}\DIFdelend \DIFaddbegin     \DIFadd{$ f$}\DIFaddend , we wish to write it as
$$\vec f = \sum_{k=1}^{n} c_{k}\vec{w}_{k}$$
where $c_{k}$ are the coefficients and $\vec{w}_{k}$ are the wavelets. The key here is that we must find a way to compute the coefficients \DIFdelbegin \DIFdel{$c_{k}$}\DIFdelend \DIFaddbegin \DIFadd{$c_{1k}$}\DIFaddend . Given a random vectors $w_{k}$, how difficult is it to calculate the $c_{k}s$.

If we have a random vector it is $\mathcal{O}(N^{3})$. If we have orthogonal vector's $\mathcal{O}(N^{2})$, if we use the FFT, we have $\mathcal{O}(N\log(N))$, but with wavelets, it is only $\mathcal{O}(N)$.

\subsubsection*{Example of wavelets}
The Haar Wavelet. Takes discrete values of $0,1,-1$.\\
The ``Mexican Hat Wavelet'' or Ricker wavelet,  which is the second derivative of a     guassian $e^{-x^{2}}$. Daubechies wavelet, which is continuous and nowhere differentiable.
\subsubsection*{Gram Schmidt Process}
To implement Gram Schmidt in MATLAB, we construct a matrix $C$ where
$$C = [ \langle u_{j},u_{k}\rangle]$$
the matrix of inner products, let $L$ be the lower triangular part of the Cholesky     decomposition, then the inverse transpose will give the coefficients of the basis in its columns.\\\\
Given vectors $\{u_{i}\}_{i=1}^{n}$, we find vectors $\{v_{i}\}_{i=1}^{n}$ that are orthonormal and span the same space as $\{u_{i}\}_{i=1}^{n}$. By Cholesky decomposition, define the matrix of vectors $u_{i}$ as its columns
$$U = \begin{bmatrix}
            u_{1}, u_{2},\dots, u_{n}
Then $U^{*}U$ is symmetric positive definite, which implies a cholesky decomposition $LL^{*}$ exists, where $L$ is lower triangular with diagonal entries are all positive. Finally, we write
$$V = U(L^{-1})^{*} = \begin{bmatrix}
                    v_{1} v_{2} \dots v_{n}
then the columns of $V$ ar ethe orthonormal vectors we want. Let us prove that these columns are orthonormal
$$V^{*}V = [U(L^{-1})^{*}]^{*} U(L^{-1})^{*} = L^{-1}U^{*} U(L^{*})^{-1} = L^{-1} L L^{*}(L^{*})^{-1} = I$$
Now let us show that $v's$ span the same space as the $u$'s. Since
\end{bmatrix} = V = U(L^{*})^{-1} = \begin{bmatrix}
                                u_{1}&u_{2}&\dots &u_{n} 
                                    \ell_{11} & \ell_{1,2} & \ell_{1,3} &\dots\\
                                    0 & \ell_{2,2} & \dots & \dots\\
                                    0 & 0 & \ell_{3,3} & \dots\\
\DIFaddbegin \DIFadd{So 
    \vec{v}_{1} }&\DIFadd{= \ell_{1,1}\vec{u}_{1}}\\
    \DIFadd{\vec{v}_{2} }&\DIFadd{= \ell_{1,3} \vec{u}_{1} + \ell_{2,2} \vec{u_{2}}}\\
    \DIFadd{\vec{v}_{3} }&\DIFadd{= \ell_{1,3} \vec{u}_{1} + \ell_{2,3}\vec{u_{2}} + \ell_{3,3}\vec{u}_{3}
\DIFadd{But what about functions? We instead take $u$  whose ``matrix'' columns are functions. Then calculate $U^{*}U$ as usual, and each element of the matrix becomes inner products.
}\begin{align*}\DIFadd{U }&\DIFadd{= \begin{bmatrix}
        1 & x & x^{2} & x^{3}
\DIFadd{UU^{*} }&\DIFadd{= \begin{bmatrix}
            \langle 1,1\rangle & \langle 1,x\rangle & \langle 1,x^{2}\rangle \\
            \dots & \dots & \dots 
  • welcome to tex.sx note you can format code (or error log) blocks using the {} button in the editor (see my edit) Dec 10, 2013 at 23:28
  • 1
    It may be hard to help without seeing the generated latex, please try to generate a small file that shows the problem and add to your answer. Dec 10, 2013 at 23:30
  • It's probably due to the fact that \DIFadd and/or \DIFdel are enclosing the contents incorrectly. Check your align* environment for misplaced braces, and correct them (or post them here if you can't find any errors), then the file should compile.
    – Herr K.
    Dec 10, 2013 at 23:40
  • @DavidCarlisle Thank you, I would have pasted the generated latex earlier, but I couldn't figure out how to display it properly.
    – Echan
    Dec 11, 2013 at 1:06
  • @user42547 it would be easier if you could make your code so that we can run it and get the error you get. ie make it a complete document showing all needed packages. Dec 11, 2013 at 1:09

2 Answers 2


The problem is that latexdiff wraps \intertext{Then} with the command \DIFadd{...}, which marks the stuff you add in the new version. But since \DIFadd is not a legitimate command inside align*, TeX throws an error. To make the code compile, replace




The last bit of output should look like this:

enter image description here

As I mentioned in my comment, most of the errors (I've encountered) given by a latexdiffed document is due to incorrect applications of the \DIFadd and/or \DIFdel commands, especially in array-type environments. There's not much one can do other than to manually correct these errors and to send the developer a bug report.

  • 1
    Thank you very much. I apologize for the large number of edits necessary to make this question answerable.
    – Echan
    Dec 11, 2013 at 21:45
  • 5
    For that particular problem, a sed 's/\DIFadd{\\intertext{\(.*\)}}/\intertext{\DIFadd{\1}}/g' filenamediff.tex on Unix system should do.
    – Clément
    May 3, 2016 at 1:40

I've found that the default options (which use underline or strikethrough) cause the most problems, as does trying to markup changes in Math mode. Changing these often gets it to work for me (though it may not be as visually pleasing), e.g., try

latexdiff --math-markup="off" -t CFONT oldFile.tex newFile.tex > differences.tex

You must log in to answer this question.

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