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

compile errors if removing a list environment #241

Open
zyrano opened this issue Oct 5, 2021 · 5 comments
Open

compile errors if removing a list environment #241

zyrano opened this issue Oct 5, 2021 · 5 comments
Labels

Comments

@zyrano
Copy link

zyrano commented Oct 5, 2021

Hi,
first latexdiff is a really great tool, thanks for developing it.

We noticed cases where it produces a .tex which contains bugs/can't be compiled.
In our document we had a glossary from which some entries have been removed. Some of these entries contain enumerate environments. However (maybe due to other changes in the defined term) the \begin{enumerate} is removed but orphaned \item statements remain.
As I may not provide the file I extract a sample of such a corrupted block but had to replace the text with dummy content.

%DIFDELCMD < \longnewglossaryentry{foo}
%DIFDELCMD < {
%DIFDELCMD <   %%%
\DIFdel{name=foo,
  plural=foos,
  see=}%DIFDELCMD < {%%%
\DIFdel{foo-data,foo-parameter,foo-xml,foo-result}%DIFDELCMD < }
%DIFDELCMD < }
%DIFDELCMD < {
%DIFDELCMD <   \begin{enumerate}[label=\alph*)]
%DIFDELCMD <     \item %%%
\item\DIFdel{A bar (.zip), which
    }%DIFDELCMD < \item[] %%%
\item[]\DIFdel{or
    }%DIFDELCMD < \item %%%
\item\DIFdel{something else, }%DIFDELCMD < \dots%%%
\DIFdel{)
  }%DIFDELCMD < \item[] %%%
\item[]\DIFdel{or
    }%DIFDELCMD < \item %%%
\item\DIFdel{baz
    }%DIFDELCMD < \item[] %%%
\item[]\DIFdel{or
    }%DIFDELCMD < \item %%%
\item\DIFdel{a set of.
  }%DIFDELCMD < \end{enumerate}
%DIFDELCMD <   %%%
\DIFdel{Depending on the context this includes \dots.
}%DIFDELCMD < }
%DIFDELCMD <

Version is
latexdiff-vc --version
This is LATEXDIFF-VC 1.3.0
(c) 2005-2018 F J Tilmann

We also encountered some issues with added chapters but these are negligible for now ...

@ftilmann
Copy link
Owner

ftilmann commented Oct 5, 2021

Thanks for reporting. List environments are a somewhat known weakness. Any chance of getting a sanitised example of old and new text leading to this outcome. Otherwise this will be hard to debug.

@zyrano
Copy link
Author

zyrano commented Oct 8, 2021

In the following I provide a sanitized example with the following restrictions:

  • this is only a small part of the document (146 pages by now)
  • real content is replaced with dummy text due to legal restrictions

I try no to damage the structure when adjusting the sample text. So hopefully this can be used to reproduce the bug. Furthermore there is additional complexity as we have the single glossary entries in separate files, use a Makefile to generate the glossary.tex and then include generated the glossary.tex in our final documents. So problems may also be caused by this structure / latexpand.

Old:

\chapter{Abkürzungsverzeichnis}

\begin{acronym}[lorem]
  \acro{sample}[Sample]{Beispielprobe}
  \acroplural{sample}[samples]{Beispielproben}
\end{acronym} 
\longnewglossaryentry{ipsum}
{
  name=ipsum
}
{
    \begin{enumerate}[label=\alph*)]
    \item a cute animal
    \item[] oder
    \item some dummy text
    \item[] oder
    \item something else
    \item[] oder
    \item something totally different
  \end{enumerate}
  Depending on the context \dots.
}

\longnewglossaryentry{yellow}

New:

\chapter{Abkürzungsverzeichnis}

\begin{acronym}[lorem]
  \acro{sample}[Sample]{Beispielprobe}
  \acroplural{sample}[samples]{Beispielproben}
\end{acronym}

\printglossaries
\bibliographystyle{alpha}
\bibliography{../commons/bibliography}
\addcontentsline{toc}{chapter}{Literaturverzeichnis}
\label{bibliography}}
 
\renewcommand{\glossarypreamble}{\label{chap:glossary}}
\makeglossaries
\longnewglossaryentry{ipsum}
{
  name=ipsum
}
{
    \begin{enumerate}[label=\alph*)]
    \item a cute animal
    \item[] oder
    \item some dummy text
    \item[] oder
    \item something else
    \item[] oder
    \item something totally different
  \end{enumerate}
  Depending on the context \dots.
}

\longnewglossaryentry{yellow}

Furthermore due to the change with \makeglossaries the sample glossary entry \gls{ipsum} is only contained in the old document but not in the new one while \gls{yellow} is contained in both documents (cause in the old document the whole glossary was printed in the new document only the referenced entries and there is no \gls{ipsum} in the document).

@ftilmann
Copy link
Owner

ftilmann commented Mar 6, 2022

OK, I know it's been some time but I just looked at this again. The example you provided does not reproduce the error, as the argument of \longnewglossaryentry is the same in old.tex and new.tex, and the only difference is the `paragraph' starting with \printglossaries. Also, I am not familiar with glossaries package, nor is latexdiff, so \makeglossaries will not get expanded internally but treated atomistically, i.e. you cannot expect differences to be highlighted there. Nevertheless there should be no errors when compiling Also note that latexdiff does not recognise command arguments if there are not immediately following - it will not recognise commands separated by newlines or spaces. So writing the entry as the following:

\longnewglossaryentry{ipsum}{
  name=ipsum
}{
    \begin{enumerate}[label=\alph*)]
    \item ...
  \end{enumerate}
  Depending on the context \dots.
}

there probably will no longer be a compilation error (but also no highlighting). Alternatively, use --allow-spaces option (which can have unwanted side effects).
If you are still interested in this bug, I would need a corrected sanititized example, and this should be a full MWE, i.e. including necessary preamble, \begin{document} etc

@ftilmann ftilmann added the On hold Waiting for more input from reporter label Mar 6, 2022
@stessaris
Copy link

I'm experiencing the same bug, I think that it's triggered when all the \items start with a latex block. Below a MWE.

old.tex

\documentclass{article}

\begin{document}

Missing item error:

\begin{itemize}
    \item {\it first item}
\end{itemize}
\end{document}

new.tex

\documentclass{article}

\begin{document}

Missing item error:

no items here

\end{document}

LATEXDIFF 1.3.2 is generating a diff latex file which includes:

\begin{itemize}%DIFAUXCMD
%DIFDELCMD <     \item {\it %%%
\DIFdel{first item}%DIFDELCMD < }

\end{itemize}%DIFAUXCMD

that cannot be compiled because there're no \items inside an itemize environment.

@colluca
Copy link

colluca commented Mar 31, 2023

I can confirm that the problem seems to occur when the \item starts with a Latex block. Here is my MWE, tested on latexdiff 1.3.3.

old.tex

\documentclass{article}
\begin{document}

\begin{enumerate}
\item{First item}
\item{Second item}
\item{Third item}
\end{enumerate}

\end{document}

new.tex

\documentclass{article}
\begin{document}

\begin{enumerate}
\item{1st item}
\item{2nd item}
\item{3rd item}
\end{enumerate}

\end{document}

No diff at all is produced, but the new.tex items are present in the diff file.
When the same input files are provided without the wrapping curly braces after each \item command, the script works as expected.

I opened a question on stack exchange with some more information, before I came across this issue.
https://tex.stackexchange.com/questions/681408/latexdiff-does-not-diff-enumerate-environment

@ftilmann ftilmann added NeedFix and removed On hold Waiting for more input from reporter labels Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants