From unknown Sat Jun 14 18:47:17 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#69370 <69370@debbugs.gnu.org> To: bug#69370 <69370@debbugs.gnu.org> Subject: Status: Preview breaks with \listoftodos in article class due to chapter not being defined Reply-To: bug#69370 <69370@debbugs.gnu.org> Date: Sun, 15 Jun 2025 01:47:17 +0000 retitle 69370 Preview breaks with \listoftodos in article class due to chap= ter not being defined reassign 69370 auctex submitter 69370 Daniel Kessler severity 69370 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 25 01:36:26 2024 Received: (at submit) by debbugs.gnu.org; 25 Feb 2024 06:36:26 +0000 Received: from localhost ([127.0.0.1]:46009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1re87d-0003GH-Jb for submit@debbugs.gnu.org; Sun, 25 Feb 2024 01:36:26 -0500 Received: from lists.gnu.org ([209.51.188.17]:52430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1re1hj-0003kX-6g for submit@debbugs.gnu.org; Sat, 24 Feb 2024 18:45:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1re1H9-0005se-Kc for bug-auctex@gnu.org; Sat, 24 Feb 2024 18:17:47 -0500 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1re1H7-0006uQ-Rp for bug-auctex@gnu.org; Sat, 24 Feb 2024 18:17:47 -0500 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-21fa0ec227eso1014899fac.0 for ; Sat, 24 Feb 2024 15:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708816664; x=1709421464; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=nwbVmGrPd0RPD+WEsHJbxlrClACSujr21bfKnEIuqpo=; b=Ap+TnAA53IDewkiTxZ3TRxJxqnyWDNgU0WAYBYCHqjvbbn8in53tbJlPtoyY//YQrV Dnv+eemEP/zqL2lFCuQmE+qAKDklmAUjSHqT3YPcq1jlnaL+xj9UaQVHL4RdH+D8Hz0K c9j2Wy6e1gZXyuwKmPo+fvIeWwNnU+dgFqIfVW9Pgw88auxZtgtHQ62YC2KSUeRWbK/v NqIcO2eRiZqKxTqOCvdKW0wGRD0P7qh6nxxKhse+wZLWE7MC7wNr8qc6waHNvWU+dzn6 MBbvA8oKcsAWP0viwx7V0/2ysDFxjMQvmV050SCGQyaJP6cgBNq2730Bt16EvAmxxc5C 9t4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708816664; x=1709421464; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nwbVmGrPd0RPD+WEsHJbxlrClACSujr21bfKnEIuqpo=; b=FCf3vtyiU8PXXZxyyL3uKfNKZViN8L6zizGp7PPK0d1b6xGx1IS0GU2L4YtHDXlIRk HvCpswxbhpVJGR2sj2Bvk6jANA+hYvKM5tOPt6GjeqseV6Uy34/vieIyCzRud0tjCvnO q0uequ5rV0ZEIDCrRHAtyzV87nUdouKB0C5C7i7ezXR5pjmmU4GzjbX+VXMiZyKKYhTK gemAhrx1S2PZJQe3SPnicZnhTulJQuuhxDpb8XMbNRSiy5IL8UpLKPIGwIXatrFryzCZ sjtcTfq7P03A1Lunb1TEbqHQqsjPE/Oy1DxQTDtFD7pcKiCJXUgkw2H//JUdFYCzxh/c 7jgA== X-Gm-Message-State: AOJu0YxAC7Je7KRZ2TQqMq3889/E5JcKoRqmhJSPZYzerB2F7kfo8yhw zYZpZPjCEz+NTOnknSVzLDFuG2vlkWtoCWZdaZKFOIFvE8LbPyzf7okiJR02stvCy/dl6+Pm8a4 fH9RGzyNMyP2v3VIcz/33pVf9yp3mjrl0A8s= X-Google-Smtp-Source: AGHT+IFQ7RCfpJS05wa8LX84f+WfczCowTYEiTPy6kmPmovGZSN9yFH5SafMBKWGD0IU1pxHTnuHjM6F+6rlg5lB8oc= X-Received: by 2002:a05:6870:231f:b0:21e:8a73:f45e with SMTP id w31-20020a056870231f00b0021e8a73f45emr4184518oao.16.1708816663710; Sat, 24 Feb 2024 15:17:43 -0800 (PST) MIME-Version: 1.0 From: Daniel Kessler Date: Sat, 24 Feb 2024 15:17:32 -0800 Message-ID: Subject: Preview breaks with \listoftodos in article class due to chapter not being defined To: bug-auctex@gnu.org Content-Type: multipart/alternative; boundary="0000000000003a10aa061228e2d1" Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=dankessler@gmail.com; helo=mail-oa1-x2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 25 Feb 2024 01:36:07 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --0000000000003a10aa061228e2d1 Content-Type: text/plain; charset="UTF-8" I noticed that when I attempted to preview some latex buffers in emacs, that the compilation process would get stuck and hang when it encountered the \listoftodos macro from the todonotes package. Here's the definition of \listoftodos: \newcommand{\listoftodos}[1][\@todonotes@todolistname] {\@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \@starttoc{tdo}} I was able to reproduce the issue outside of emacs/AUCTeX and noticed that the issue seemed to be that it had encountered the unknown command \chapter* (these errors were suppressed by the auctex option when using preview from within emacs). In brief, \listoftodos behaves differently depending on whether or not \chapter is defined (and in the article class, it isn't). However, when preview is active and the sections option is passed, it runs \PreviewMacro[*[[!]{\chapter}%]] *regardless *of whether chapter is defined or not. The \PreviewMacro command is a bit mysterious to me, but as far as I can tell it defines \chapter in such a way that it will expand to a macro that does some preprocessing first, calls the original definition of chapter, and (perhaps) does some postprocessing. However, that second step will fail since \chapter doesn't have an original definition in the article class. Here's an MWE latex file that demonstrates the issue with todonotes's \listoftodos: \documentclass{article} \usepackage{todonotes} \usepackage[active,sections]{preview} \begin{document} \listoftodos \end{document} However, the problem isn't really with todonotes specifically, as can be appreciated with the following two MWE latex files that demonstrate the crux of the issue with chapter without involving todonotes at all. The first yields an error, the second compiles cleanly. They differ only in whether the preview package is active or not. \documentclass{article} \usepackage[active,sections]{preview} \begin{document} \makeatletter \@ifundefined{chapter}{\section{Section One}}{\chapter{Chapter One}} \makeatother \end{document} vs \documentclass{article} \usepackage[inactive,sections]{preview} \begin{document} \makeatletter \@ifundefined{chapter}{\section{Section One}}{\chapter{Chapter One}} \makeatother \end{document} Compiling the first yields ! Undefined control sequence. \pr@\chapter {Chapter One} l.7 ...ection{Section One}}{\chapter{Chapter One}} I think this could be fixed by adding some logic into around where the sections options is declared so that \PreviewMacro[*[[!]{\chapter}%]] is run *only* if \chapter is already defined. Perhaps there's some additional logic that be built into the \PreviewMacro instead, but the code used in that definition exceeds my understanding of (la)tex. -Dan --0000000000003a10aa061228e2d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I= noticed that when I attempted to preview some latex buffers in emacs, that= the compilation process would get stuck and hang when it encountered the \= listoftodos macro from the todonotes package. Here's the definition of = \listoftodos:

\newcommand{\listoftodos}[1][\@todonotes@todolistnam= e]
=C2=A0 =C2=A0 {\@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \= @starttoc{tdo}}

I was able to reproduce the= issue outside of emacs/AUCTeX and noticed that the issue seemed to be that= it had encountered the unknown command \chapter* (these errors were suppre= ssed by the auctex option when using preview from within emacs). In brief, = \listoftodos behaves differently depending on whether or not \chapter is de= fined (and in the article class, it isn't). However, when preview is ac= tive and the sections option is passed, it runs

=C2=A0 \PreviewMacro[*[[!]{\chapter}%]]

regardless of whether chapter is defined or = not. The \PreviewMacro command is a bit mysterious to me, but as far as I c= an tell it defines \chapter in such a way that it will expand to a macro th= at does some preprocessing first, calls the original definition of chapter,= and (perhaps) does some postprocessing. However, that second step will fai= l since \chapter doesn't have an original definition in the article cla= ss.

Here's an MWE latex file that demonstrates= the issue with todonotes's=C2=A0\listoftodos:

\documentclass{article}
\usepackage{todonotes}=
\usepackage[active,sections]{preview}
\begin{document}
\listoftod= os
\end{document}


However, the probl= em isn't really with todonotes specifically, as can be appreciated with= the following two MWE latex files that demonstrate the crux of the issue w= ith chapter without involving todonotes at all. The first yields an error, = the second compiles cleanly. They differ only in whether the preview packag= e is active=C2=A0or not.

\documentclass{article}
\use= package[active,sections]{preview}
\begin{document}
\makeatletter
\@ifundefined{chapter}{\section{Se= ction One}}{\chapter{Chapter One}}
\makeatother
\end{document}

vs

\documentclass{article= }
\usepackage[inactive,sections]{= preview}
\begin{document}<= /div>
\makeatletter
\@ifundefined{chapter}{\section{Section One}}{\chapter{Chap= ter One}}
\makeatother
\end{document}

<= /div>
Compiling the first yields=C2=A0

! Undefined control sequence.
<argument> \pr@\chapter=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {Chapter One}
l.7 ...ection{Section One}}{\chapter{Chapter One}}

I think this could be fixed by adding som= e logic into around where the sections options is declared so that=C2=A0 = =C2=A0

\PreviewMacro[*[[!= ]{\chapter}%]]

<= div>is run *only* if \chapter is already defined. Perhaps there's some = additional logic that be built into the \PreviewMacro instead, but the code= used in that definition exceeds my understanding of (la)tex.
-Dan





--0000000000003a10aa061228e2d1--