Subject: bug#58009: AUCTex and algorithm package

From: Arash Esbati <[email-masked]>
Date: Fri, 08 Mar 2024 22:01:25 +0100

Arash Esbati <[email-masked]> writes:

> Hi Alejandro,
>
> Alejandro Garzon <[email-masked]> writes:
>
>> I'm having a problem while generating equations (and float) previews
>> for the attached minimal working example, bug_report.tex. The problem
>> seems to be related to the package "algorithm". When the file is
>> opened into a buffer in Emacs, the AUCTeX menu becomes available. I
>> try to generate the previews from the menu, selecting Preview ->
>> Generate previews - for buffer. However, the generation of the
>> previews stops at line 130 , where the \begin{algorithm}[H] command
>> is. A file with the error output, bug_log.txt, is attached. The
>> generation of the previews completes successfully when the lines 130
>> to 140, the full instance of use of the algorithm environment, are
>> commented out.
>
> Thanks for the report.  I remember we had reports about the float
> package not being really compatible with Preview.  And I think this is
> the issue since the algorithm package only loads float.sty and defines a
> new environment.  Interestingly, I can run this small document through
> Preview which generates some LaTeX errors but finally shows the snippets
> in Emacs:
>
> \documentclass[twocolumn]{article}
>
> \usepackage{algorithm}
> \usepackage{algorithmic}
> \usepackage{amsmath}
> \usepackage{lipsum}
>
> \newcommand{\tp}{\mathsf{T}}
> \newcommand{\wt}[1]{\widetilde{#1}}
>
> \begin{document}
>
> \section{Model equations}
>
> \lipsum[1-1]
> \begin{align}\label{eq:puwtLu}
>   \partial_tu&=\widetilde{L}u + F(u),
> \end{align}
>
> \lipsum[2-2]
> \begin{align}
>   \label{eq:nu1E}
>   \mathbf{n}\cdot(\nabla u_1 - E)= 0,
> \end{align}
>
> \lipsum[3-3]
> \begin{equation}
>   \label{eq:nui}
>   {\bf n}\cdot\nabla u_i= 0.
> \end{equation}
>
> \lipsum[4-4]
> \begin{equation*}
>   \int_0^T [E(t)]^2dt.
> \end{equation*}
>
> \lipsum[5-5]
> \begin{algorithm}% [H]
>   \algsetup{linenosize=\normalsize}
>   \caption{Fast algorithm}
>   \label{alg:adj}
>   \begin{algorithmic}[1]
>     \STATE $a \gets b$
>     \STATE $b \gets c$
>     \STATE $c \gets d$
>   \end{algorithmic}
> \end{algorithm}
>
> \lipsum[5-5]
> \begin{equation}
>   \label{eq:calJi}
>   \widetilde{\cal J}_i = \int_\Omega \left\|\nabla u_i\right\|_{t=T}^2\,d\Omega.
> \end{equation}
>
> \lipsum[5-5]
> \begin{equation}
>   \label{eq:L0}
>   \widetilde{\cal L}_0=\frac{1}{2}\sum_{i=1}^n\gamma_i \widetilde{\cal J}_i
>   +\frac{\alpha}{2}\int_0^T [E(t)]^2\,dt.
> \end{equation}
>
> \end{document}
>
> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
>
> So I think the combination revtex4-2.cls and float.sty breaks with
> Preview.
>
>> A workaround for this problem, which I will try, is to use an
>> alternative to the package algorithm, like algorithm2e. However, I
>> thought it would be of interest for you to know about this problem and
>> to warn the community of AUCTeX users about it.
>
> Thanks, but I'm not sure if we will manage to fix this issue since the
> principle author of Preview is inactive now.  So we will see.

I don't think we will be able to fix this issue since the principle
author of preview-latex is inactive.  Therefore I'm closing this report
as "wontfix".  We can reopen if things change.

Best, Arash