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

[BUG] Lemma numbered correctly in appendix when using SIAM style file #14

Open
dpo opened this issue Aug 10, 2023 · 9 comments
Open

[BUG] Lemma numbered correctly in appendix when using SIAM style file #14

dpo opened this issue Aug 10, 2023 · 9 comments

Comments

@dpo
Copy link

dpo commented Aug 10, 2023

Describe the bug

Lemma is numbered correctly in the appendix when using the SIAM style file.

To Reproduce: Minimal Working Example

% \documentclass{siamart220329}

\documentclass{article}
\usepackage{amssymb,amsmath,amsthm}
\newtheorem{lemma}{Lemma}[section]
\newtheorem{theorem}{Theorem}[section]
\newcommand{\lemmaautorefname}{Lemma}

\usepackage[createShortEnv, conf={one big link}]{proof-at-the-end}

\begin{document}

\section{Important Results}

\begin{lemmaE}[][end, restate]
  Life is not easy.
\end{lemmaE}

\begin{proofE}
  Immediate.
\end{proofE}

\begin{theoremE}[][end, restate]
  Life is hard.
\end{theoremE}

\begin{proofE}
  The result is direct.
\end{proofE}

\appendix

\section{Proofs}

\printProofs

\end{document}

Version
Output of latex --version:

$ latex --version
pdfTeX 3.141592653-2.6-1.40.25 (TeX Live 2023)
kpathsea version 6.3.5
Copyright 2023 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.39; using libpng 1.6.39
Compiled with zlib 1.2.13; using zlib 1.2.13
Compiled with xpdf version 4.04

Version of proof-at-the-end: 2022/02/07

Additional context

The lemma and theorem numbers are correct when compiling the document above. However, if you uncomment the first line and comment out the next five (in order to use the SIAM style file), the reference of the lemma is displayed as "Lemma A.1" instead of "Lemma 1.1", and the proof line says "Proof of Theorem 1.1" instead of "Proof of Lemma 1.1".

In addition, a "QED" symbol (a white square) is supposed to appear automatically upon \end{proof}, but it no longer does in the proofE environment.

Here is a link to their style file: https://epubs.siam.org/pb-assets/macros/standard/siamart220329.cls

Do you have any idea where the conflict could be?

Thank you in advance!

@tobiasBora
Copy link
Contributor

tobiasBora commented Aug 10, 2023 via email

@tobiasBora
Copy link
Contributor

tobiasBora commented Aug 12, 2023

Ok, so I confirm that cref is more stable with SIAM and fix one of the two bugs, so load the package with commandRef=Cref:

\usepackage[
  createShortEnv,
  conf={one big link},
  %% Use Cref that seems more resilient than autoref in SIAM
  commandRef=Cref]{proof-at-the-end}

the second bug comes from thm-restate that I use internally. By default it only saves the equation counter, but we can ask it to save the current section number to avoid bad numbering with:

\makeatletter
\def\thmt@innercounters{section,equation} %% default is equation, we also need to save the section number in the restate
\makeatother

The whole code becomes:

\documentclass{siamart220329}

\usepackage[
  createShortEnv,
  conf={one big link},
  %% Use Cref that seems more resilient that autoref in SIAM
  commandRef=Cref]{proof-at-the-end}
\makeatletter
\def\thmt@innercounters{section,equation} %% default is equation, we also need to save the section number in the restate
\makeatother
\begin{document}

\section{Important Results}

\begin{lemmaE}[][end, restate]
  Life is not easy.
\end{lemmaE}

\begin{proofE}
  Immediate.
\end{proofE}

\begin{theoremE}[][end, restate]
  Life is hard.
\end{theoremE}

\begin{proofE}
  The result is direct.
\end{proofE}

\appendix

\section{Proofs}

\printProofs

\end{document}

image

Let me know if it works for you. If not, I will re-open it.

@dpo
Copy link
Author

dpo commented Aug 20, 2023

Thank you, that is a big improvement. There remains an issue with the "qed" symbol (a white square) that is inserted at the end of each proof in the SIAM style. When using your package, the symbol either disappears or appears in odd locations.

@tobiasBora
Copy link
Contributor

This seems like the fault comes from the weird implementation of proof in SIAM. Notably, it seems to add a qed symbol only if there is a new line before the \end{proof}, but no empty line:

\begin{proof}[Proof of my theorem]
  This is with a new line before and a new line after.
\end{proof}

\begin{proof}[Proof of my theorem]Exactly identical, but with no space before, but one after.
\end{proof}

\begin{proof}[Proof of my theorem]Exactly identical, but with no space before nor after.\end{proof}

Gives:

image

The problem is that my library removes all new lines, because LaTeX seems to be fundamentally unable to detect/copy them without using verbatim environment, but these have other issues (notably, they can't be used inside other environments). The simpler solution is certainly to redefine the proof environment so that it always add a qed even if there is no line. You can maybe just copy the definition from amsthm (will try it later).

@tobiasBora
Copy link
Contributor

tobiasBora commented Aug 21, 2023

Ok, so a simple workaround is to add \space before all \end{proofE}, like in:

\begin{proofE}
  Immediate.
  \space %% Otherwise, siamart does not add the qed symbol.
\end{proofE}

One can easily define a new environment proofEE that adds this space automatically (I am a bit reluctant to add this space by default in the library as this issue seems very related with how SIAM defines proof… or maybe I can automatically detect if I am in SIAM and add a space in that case). This gives this MWE:

\documentclass{siamart220329}

\usepackage[
  createShortEnv,
  conf={one big link},
  %% Use Cref that seems more resilient that autoref in SIAM
  commandRef=Cref]{proof-at-the-end}
\makeatletter
\def\thmt@innercounters{section,equation} %% default is equation, we also need to save the section number in the restate
\makeatother

%%% Defines a new environment that automatically adds the space
%%% to fix https://github.com/leo-colisson/proof-at-the-end/issues/14
\NewDocumentEnvironment{proofEE}{O{}+b}{%
  \begin{proofE}[#1]
    #2
    \space
  \end{proofE}
}{}


\begin{document}

\section{Important Results}

\begin{lemmaE}[][end, restate]
  Life is not easy.
\end{lemmaE}

\begin{proofEE}
  Immediate.
\end{proofEE}

\begin{theoremE}[][end, restate]
  Life is hard.
\end{theoremE}

\begin{proofEE}
  The result is direct.
\end{proofEE}

\appendix

\section{Proofs}

\printProofs

\end{document}

that produces:

image

Hopefully it will solve your issues. I don't know if there is a cleaner way that does not copy/paste the proof definition of amsthm.

@tobiasBora tobiasBora reopened this Aug 21, 2023
@tobiasBora
Copy link
Contributor

I will reopen until I document properly this case.

@tobiasBora
Copy link
Contributor

Also, regarding the eratic position of the QED symbol, you might be interested by this question https://tex.stackexchange.com/questions/329159/erratic-position-of-qed-symbol-at-the-end-of-proof-environment-using-siam-templa

@dpo
Copy link
Author

dpo commented Aug 21, 2023

Thank you so much! We are 99.99% there. Here is one more glitch with the numbering of lemmas. I added a new section and a lemma under it:

\documentclass{siamart220329}

\usepackage[
  createShortEnv,
  conf={one big link},
  %% Use Cref that seems more resilient that autoref in SIAM
  commandRef=Cref]{proof-at-the-end}
\makeatletter
\def\thmt@innercounters{section,equation} %% default is equation, we also need to save the section number in the restate
\makeatother

%%% Defines a new environment that automatically adds the space
%%% to fix https://github.com/leo-colisson/proof-at-the-end/issues/14
\NewDocumentEnvironment{proofEE}{O{}+b}{%
  \begin{proofE}[#1]
    #2
    \space
  \end{proofE}
}{}


\begin{document}

\section{Important Results}

\begin{lemmaE}[][end, restate]
  Life is not easy.
\end{lemmaE}

\begin{proofEE}
  Immediate.
\end{proofEE}

\begin{theoremE}[][end, restate]
  Life is hard.
\end{theoremE}

\begin{proofEE}
  The result is direct.
\end{proofEE}

\section{A New Section}

\begin{lemmaE}[][end, restate]
  Life is definitely not easy.
\end{lemmaE}

\begin{proofEE}
  Still working on the proof.
\end{proofEE}

\appendix

\section{Proofs}

\printProofs

\end{document}

The new lemma has number 2.1. However, in the appendix, we see "Lemma 2.2 ... Proof of Lemma 2.1 ...".

@dpo
Copy link
Author

dpo commented Aug 21, 2023

The solution seems to be:

\makeatletter
\def\thmt@innercounters{section,equation,theorem} %% <-- add theorem counter here
\makeatother

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants