leo-colisson / proof-at-the-end

This package aims to provide a way to easily move LaTeX proofs in appendix.
Other
24 stars 4 forks source link

[BUG] proof-at-the-end-package breaks \chapter macro in komascript classes #11

Closed mw88-personal closed 2 years ago

mw88-personal commented 2 years ago

Describe the bug When used in conjunction with any komascript class, e.g. scrbook, scrreport, the loading of package proof-at-the-end breaks the \chapter macro. If I load a different class, e.g. book, it works fine, though. Can you confirm this is a bug, and suggest a solution, as I really would like to use proof-at-the-end in my notes, and can not deviate from scrbook.

To Reproduce: Minimal Working Example

% file: mwe.tex
\documentclass{scrreport}

\usepackage{proof-at-the-end}

\begin{document}
Test
\chapter{Testchap}
 asdf
\end{document}

produces error output:

$ pdflatex mwe
...
! Missing \endcsname inserted.
<to be read again> 
                   \edef 
l.7 \chapter{Testchap}

Version Output of latex --version:

$ latex --version
pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022)
kpathsea version 6.3.4
Copyright 2022 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.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03

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

tobiasBora commented 2 years ago

Thanks a lot for the report. I confirm the bug, I'll investigate now.

tobiasBora commented 2 years ago

Ok so it seems that the problem is coming from the line:

\AtEndPreamble{%
  \RequirePackage{hyperref}
}%

so a quick workaround is to copy the .sty file in your project and to remove this line and to manually load hyperref if needed. Meanwhile I'll look for the proper way to do that in komascript.

-- EDIT -- Argh forget what I just said, I think the problem comes from the way I patch chapters… I'll come back soonish hopefully.

tobiasBora commented 2 years ago

So to disable the error, one can do:

\usepackage[disablePatchSection]{proof-at-the-end}

but then the section will be poorly numbered if you use the text link section. One workaround is to manually add \pratendAddLabel after the chapters like in:

\documentclass{scrreport}

\usepackage[disablePatchSection]{proof-at-the-end}

\begin{document}
Test
\chapter{Testchap}\pratendAddLabel
 asdf
\end{document}

But I'll try to find how to properly patch chapters in komascript.

mw88-personal commented 2 years ago

Thanks for working on it. I can confirm the workaround https://github.com/leo-colisson/proof-at-the-end/issues/11#issuecomment-1225482214 does indeed work.

However, I need to ship this with my own class and sell this package to my collegues, so I would prefer a more durable and standard solution, so this can be only temporary for me.

tobiasBora commented 2 years ago

The lastest version should fix this issue. You can try it by copy/pasting the .sty file in your project, and test it, e.g., using:

\documentclass{scrreport} %% Works with both memoir and scrreport
\usepackage{lipsum}
\usepackage{thmtools}
\usepackage{amsthm}
\usepackage[commandRef=cref,createShortEnv,conf={text link section}]{proof-at-the-end}
\newtheorem{thm}{Theorem}[section]
\usepackage{hyperref}
\usepackage{cleveref}
\crefname{thm}{Theorem}{Theorems}

\begin{document}

\lipsum[1]

\chapter{Here is my title}

\lipsum[1]

\section{Here is my section}\label{mysection}

\begin{thmE}[][end]\label{mytheorem}
Here is my important theorem  
\end{thmE}
\begin{proofE}
  Here is the proof
\end{proofE}

\chapter{Proofs}\label{coucou}

\printProofs

\end{document}
mw88-personal commented 2 years ago

Thank you, that seems to work. Now I only have to wait till this fix is in the TeXlive repositories.

tobiasBora commented 2 years ago

It has been accepted, it should appear within 24 hours.