Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment "alignat" incorrectly parsed #65

Closed
tdegeus opened this issue Nov 25, 2016 · 6 comments
Closed

Environment "alignat" incorrectly parsed #65

tdegeus opened this issue Nov 25, 2016 · 6 comments

Comments

@tdegeus
Copy link
Contributor

tdegeus commented Nov 25, 2016

I have ran into a bug concerning the following piece of LaTeX code:

\begin{alignat}{2}
  ...
\end{alignat}

In my case there is no different between the two TeX-files that I compare. However, this piece of code is parsed to the following output:

\begin{align}at{2}
  ...
\end{align}

which is obviously incorrect (and problematic).

Thanks for the effort. And thanks for the great program, BTW!
Tom

@ftilmann
Copy link
Owner

ftilmann commented Nov 25, 2016

Hi with the extremely simple MWE for both old and new file:

\begin{alignat}{2}
ipsem loret
\end{alignat}

I failed to reproduce your bug. Can you construct a full MWE and attach and the exact command you used for calling.

@tdegeus
Copy link
Contributor Author

tdegeus commented Nov 25, 2016

@ftilmann that's quick. I have been able to reproduce the following minimal example.

old_min.tex

\documentclass{goose-article}

\begin{document}

\begin{alignat}{2}
  ...
\end{alignat}

\begin{equation}\label{eq:elas:C}
\end{equation}

\begin{equation}\label{eq:elas:lam-mu}
  \lambda = \frac{E \nu}{ (1+\nu)(1-2\nu)} \qquad
\end{equation}

\end{document}

new_min.tex

\documentclass{goose-article}

\begin{document}

\begin{alignat}{2}
  ...
\end{alignat}

\begin{equation}\label{eq:elas:C}
\end{equation}

\begin{equation}
  \mu     = \frac{E    }{2(1+\nu)        }
\end{equation}

\end{document}

I run the following command:

$ latexdiff --exclude-textcmd="section,subsection" old_min.tex new_min.tex > diff.tex

To find diff.tex

\documentclass{goose-article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old_min.tex   Fri Nov 25 12:39:38 2016
%DIF ADD new_min.tex   Fri Nov 25 12:39:41 2016
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\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
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %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
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

\begin{align}at{2}
  ...
\end{align}

\begin{equation}\label{eq:elas:C}
\end{equation}

\begin{equation}\DIFdelbegin %DIFDELCMD < %DIFDELCMD < \label{eq:elas:lam-mu}%%%
%DIFDELCMD <   %%%
\DIFdel{\lambda }\DIFdelend 
  \DIFaddbegin \DIFadd{\mu     }\DIFaddend = \DIFdelbegin \DIFdel{\frac{E \nu}{ (1+\nu)(1-2\nu)} }%DIFDELCMD < \qquad
%DIFDELCMD < %%%
\DIFdelend \DIFaddbegin \DIFadd{\frac{E    }{2(1+\nu)        }
}\DIFaddend \end{equation}

\end{document}

Note:

$ latexdiff --version
This is LATEXDIFF 1.1.1  (Algorithm::Diff 1.15 so, Perl v5.18.2)
  (c) 2004-2015 F J Tilmann

Hope this helps!

@ftilmann
Copy link
Owner

ftilmann commented Nov 25, 2016 via email

@tdegeus
Copy link
Contributor Author

tdegeus commented Nov 25, 2016

I agree that it is truly bizar. So much so that I had to write a Python script to iteratively trim down my file to this minimal example.

@ftilmann
Copy link
Owner

Found the problem. The bug turned out to be in a contributed subroutine, so I had to get my head around how that one worked first. The faulty line is only activated if there is an equation with a \frac command in any equation, and the bug (currently) only affects alignat (because align starts with the same letters).
Your carefully constructed minimal example helped a lot in nailing this quickly (I am not normally that responsive, just had another task that I wanted to avoid :-) ). If you don't want to update, there are only a few lines that need changing, which could implemented by hand (the commit also contains some cosmetic changes, though).
PS: I know the equation in your example from elasticity theory relating Lame Parameters to Young's modulus (?) and Poisson ratio.
Fixed with commit e39bf4e

@tdegeus
Copy link
Contributor Author

tdegeus commented Nov 25, 2016

Thanks! Really appreciate it!

Yes, it is indeed from elasticity theory. We have developed an FFT-based solver for mechanics, and are about the submit the review (see https://arxiv.org/abs/1603.08893).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants