ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
513 stars 72 forks source link

Nested list (itemize) environments #211

Closed pereimer closed 3 years ago

pereimer commented 3 years ago

latexdiff seems to not handle nested list environments. Here are two very simple .tex files for which latexdiff produces code that will not latex because of a \begin{itemize}...\end{itemize} pair with no \items

\documentclass[11pt]{article}
\begin{document}
\begin{enumerate}

\item{Main Item
  \begin{itemize}
    \item {First sub-item}
  \end{itemize}
}
\end{enumerate}
\end{document}

and

\documentclass[11pt]{article}
\begin{document}
\begin{enumerate}

\item{Almost Main Item
 \begin{itemize}
  \item {First sub-item}
 \end{itemize}
}
\end{enumerate}

\end{document}

I am using

~/Documents/local/latexdiff/latexdiff --version
This is LATEXDIFF 1.3.1.1 (Algorithm::Diff 1.1902, Perl v5.18.4)
  (c) 2004-2020 F J Tilmann

Thanks in advance

ftilmann commented 3 years ago

The problem here is that in \item{...} the part between the braces is interpreted by latexdiff to be the argument of \item while to latex it is \item + {...}. The braces are not needed, and I would argue the more canonical way is to write it without the braces. Alternatively, introduce a space between the item and the brace. So either of these variants work (just shown for the old file):

\begin{enumerate}
\item Main Item
  \begin{itemize}
    \item {First sub-item}
  \end{itemize}
\end{enumerate}

or

\begin{enumerate}
\item {Main Item
  \begin{itemize}
    \item {First sub-item}
  \end{itemize} }
\end{enumerate}