Subject: bug#29401: 11.90.2.2017-07-25; Folding displays errors on valid LaTeX

From: Arash Esbati <[email-masked]>
Date: Fri, 01 Dec 2017 08:30:44 +0100

Koen van Greevenbroek <[email-masked]> writes:

> Some valid LaTeX is parsed incorrectly by AUCTeX folding functions
> (i.e. 'TeX-fold-region'), and an annoying error is displayed. Here is
> an
> example:
>
> ===========================
> \documentclass{beamer}
> \begin{document}
> \begin{frame}
>   \begin{itemize}
>   \item \textbf<1>{One}
>   \item \textbf<1>{Two}
>   \end{itemize}
> \end{frame}
> \end{document}
> ===========================

Hi Koen,

the example above compiles fine, but I think the syntax you're using is
not correct.  beamer doc says:

    The \item command is overlay specification-aware.  If an overlay
    specification is provided, the item will only be shown on the
    specified slides, see the following example.  If the \item command
    is to take an optional argument and an overlay specification, the
    overlay specification can either come first as in \item<1>[Cat] or
    come last as in \item[Cat]<1>.

I.e., \item<alert specification>[item label]<alert specification>

Why do you put alert spec between \textbf and its argument?  This version
looks better to me

    \begin{frame}
      \begin{itemize}
      \item <1>\textbf{One}
      \item <2>\textbf{Two}
      \end{itemize}
    \end{frame}

and looks like this when folded where One and Two are boldified:

    \begin{frame}
      \begin{itemize}
      * <1>One
      * <2>Two
      \end{itemize}
    \end{frame}

> Another example, which doesn't involve beamer, is the following code:
>
> ===========================
> \usepackage{titlesec}
> \titleformat{\section}{\bfseries}{\thesection}{10pt}{}[\normalfont]
> ===========================
>
> which displays as:
>
> ===========================
> \usepackage{titlesec}
> \titleformat{[Error: No content
> found]}{\bfseries}{\thesection}{10pt}{}[\normalfont]
> ===========================
>
> Maybe it would be an idea to just not fold things like this where no
> content it found, instead of displaying an error?

This one is really hard to fix.  Correctly folding preamble macros is
almost impossible.

Best, Arash