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] Synctex Navigate To The End Of The Proof Even When Debug Is Enabled. #10

Open
czhang03 opened this issue May 6, 2022 · 7 comments

Comments

@czhang03
Copy link

czhang03 commented May 6, 2022

Describe the bug
synctex will navigate to the end of the proof/theorem, instead of the exact line, even when debug mode is enabled.

To Reproduce: Minimal Working Example

\documentclass{article}

\usepackage{amsthm}
\usepackage{hyperref}
\usepackage[conf={debug}]{proof-at-the-end}

\newtheorem{lemma}{Lemma}

\begin{document}

\begin{theoremEnd}{lemma}
    This 

    is

    a 
    
    very 

    long
     
    lemma
\end{theoremEnd}

\begin{proofEnd}
    This 

    is

    a 
    
    very 

    long
     
    proof
\end{proofEnd}


\begin{lemma}
    This 

    is

    a 
    
    very 

    long
     
    lemma
\end{lemma}

\begin{proof}
    This 

    is

    a 
    
    very 

    long
     
    proof
\end{proof}

\end{document}

Version

$ latex --version
MiKTeX-pdfTeX 4.10 (MiKTeX 22.3)
© 1982 D. E. Knuth, © 1996-2021 Hàn Thế Thành
TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.8, 13-Jul-2019
compiled with curl version 7.72.0; using libcurl/7.72.0 Schannel
compiled with expat version 2.2.10; using expat_2.2.10
compiled with jpeg version 9.4
compiled with liblzma version 50020052; using 50020052
compiled with libpng version 1.6.37; using 1.6.37
compiled with libressl version LibreSSL 3.1.4; using LibreSSL 3.1.4
compiled with MiKTeX Application Framework version 4.4; using 4.4
compiled with MiKTeX Core version 4.12; using 4.12
compiled with MiKTeX Archive Extractor version 4.0; using 4.0
compiled with MiKTeX Package Manager version 4.7; using 4.7
compiled with uriparser version 0.9.4
compiled with xpdf version 4.02
compiled with zlib version 1.2.11; using 1.2.11

Version of proof-at-the-end: Packaged on Tue Feb 8 16:11:27 2022 or the GitHub version works the same.

Additional context
I am using vscode with LaTeX workshop, and synctex version 1.5.

When I synctex on a line in a theroemEnd or proofEnd, I get navigated to the line \end{theroemEnd} or \end{proofEnd}, even with debug enabled. Whereas in the normal lemma and proof environment, I get navigated to the exact line corresponding to the place I clicked.

@czhang03
Copy link
Author

czhang03 commented May 6, 2022

I think the more reasonable behavior is that when debug is enabled, proofEnd environment simply become an alias for proof environment.

It seems like debug exactly make the proofEnd env to proof env, then maybe is just a problem with synctex doesn't mix with compiler flag?

@tobiasBora
Copy link
Contributor

Hum, seems like you are right… Not sure why I never spotted it before, I was more or less sure that before it was working fine… but maybe not. I'll try to see if it's not a regression, and investigate (synctex is not really flexible ^^). Thanks!

@tobiasBora
Copy link
Contributor

tobiasBora commented May 6, 2022

Ok, so I tried with an older version and the issue was already present (maybe it was just a dream that this worked in older versions). So in fact, it seems that as soon one needs to capture the content of the environment, we lose the synctex behavior. This is visible on creating a really small example using either xparse and the +b environment option, or environ.

I'm not sure if this is fundamental or not, so I tried to ask a question here. If I can't find any solution, I will surely define a way to locally redefine the theoremEnd environment. For now, as a workaround, you can put:

  \RenewDocumentEnvironment{theoremEnd}{O{}mO{}}{\begin{#2}}{\end{#2}}
  \RenewDocumentEnvironment{proofEnd}{O{}}{\begin{proof}}{\end{proof}}

before the theorem that should be debugged (or at the beginning of the file if you want to debug everything). If you want to debug a single theorem, you can put these definitions and the theorem in a group (i.e. embraced by brackets {...}).

@tobiasBora
Copy link
Contributor

Due to the way LaTeX works, there is no nice way to add arguments like debug since the whole macro definition must be redefined. So I defined some shortcuts, like \begin{theoremEndDebug} and \begin{proofEndDebug} enables the debug version for theorems and proofs (do not forgot to set the proof if you set the theorem), same for thmE that becomes thmED… and you can also use \proofEnableDebugSynctex{} to enable globally the debug mode (warning: it won't work with restate).

Your example now becomes:

\documentclass{article}

\usepackage{amsthm}
\usepackage{hyperref}
\usepackage[conf={}]{proof-at-the-end}

\newtheorem{lemma}{Lemma}

\begin{document}


%% Or use
%% \proofEnableDebugSynctex{}

\begin{theoremEndDebug}{lemma}
    This 

    is

    a 
    
    very 

    long
     
    lemma
\end{theoremEndDebug}

\begin{proofEndDebug}
    This 

    is

    a 
    
    very 

    long
     
    proof
\end{proofEndDebug}


\begin{lemma}
    This 

    is

    a 
    
    very 

    long
     
    lemma
\end{lemma}

\begin{proof}
    This 

    is

    a 
    
    very 

    long
     
    proof
\end{proof}


\newpage

\section{Blabla}

\printProofs
\end{document}

I keep this issue open until I document this properly.

@czhang03
Copy link
Author

czhang03 commented May 6, 2022

Yeah, but changing all to ProofEndDebug will just be like proof>

@tobiasBora
Copy link
Contributor

Kind of, except in rare cases when people provide arguments to the proofEnd, the proofEndDebug will ignore these arguments. Note that if you want to change multiples environments at once, you can use instead \proofEnableDebugSynctex{} (that internally redefines proofEnd and theoremEnd), it will enable debug mode for all subsequent theorems. I don't really see any other way due to how LaTeX works; as there is no way to both capture the content of an environment (option +b) and keep synctex working. For instance, check the restatable package, it has the same issue.

But I'm not sure to see what is your expectation. What other interface would you prefer to have?

@tobiasBora
Copy link
Contributor

I may found a solution to provide a simpler interface for this, keeping the old debug flag, thanks to this answer https://tex.stackexchange.com/a/646087/116348

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