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

too much space with restatable #40

Open
mbertucci47 opened this issue Aug 21, 2023 · 2 comments
Open

too much space with restatable #40

mbertucci47 opened this issue Aug 21, 2023 · 2 comments

Comments

@mbertucci47
Copy link
Collaborator

The theorem printed by the restatable has extra vertical space above it. The same goes for the restated theorem from a restatable* (but not the restatable* itself). There is no issue with the restated theorems from a restatable environment or theorems using the restate key. Here's an example:

\documentclass{article}
\usepackage{amsthm,thmtools,kantlipsum}

\declaretheorem{theorem}

\begin{document}

\begin{theorem}
\kant[2][1]
\end{theorem}

\begin{theorem}[restate=foo]
\kant[1][2]
\end{theorem}

\begin{theorem}
\kant[2][1]
\end{theorem}

\foo*

\begin{theorem}
\kant[2][1]
\end{theorem}

\begin{restatable}{theorem}{foobar}
\kant[1][3]
\end{restatable}

\begin{theorem}
\kant[2][1]
\end{theorem}

\foobar*

\begin{theorem}
\kant[2][1]
\end{theorem}

\begin{restatable*}{theorem}{blub}
\kant[1][4]
\end{restatable*}

\begin{theorem}
\kant[2][1]
\end{theorem}

\blub

\begin{theorem}
\kant[2][1]
\end{theorem}

\end{document}

document-1

Apologies for the length; I wanted to show all possible behaviors with normal theorems interspersed. The space above the restatable environment theorem and the restated \blub is too big.

@mbertucci47 mbertucci47 changed the title extra space with restatable too much space with restatable Aug 21, 2023
@mbertucci47
Copy link
Collaborator Author

mbertucci47 commented Aug 28, 2023

A glance at the thm-restate code shows the issue is with the true branch of \ifthmt@thisistheone. A further glance shows the issue is in \thmt@rst@storecounters, called on line 119. I don't really know what I'm talking about but I think the \label{thmt@@#1@data} is inserting a "whatsit" that's adding the undesired space. If I comment it the space goes away

@mbertucci47
Copy link
Collaborator Author

This TeXSE question shows how to fix this if hyperref is loaded. Redefining \thmt@rst@storecounters as

\def\thmt@rst@storecounters#1{%
  \bgroup
  \def\@currentlabel{}%
  \@for\thmt@ctr:=\thmt@innercounters\do{%
    \thmt@sanitizethe{\thmt@ctr}%
    \protected@edef\@currentlabel{%
      \@currentlabel
      \protect\def\@xa\protect\csname the\thmt@ctr\endcsname{%
        \csname the\thmt@ctr\endcsname}%
      \ifcsname theH\thmt@ctr\endcsname
        \protect\def\@xa\protect\csname theH\thmt@ctr\endcsname{%
          (restate \protect\theHthmt@dummyctr)\csname theH\thmt@ctr\endcsname}%
      \fi
      \protect\setcounter{\thmt@ctr}{\number\csname c@\thmt@ctr\endcsname}%
    }%
  }%
  \Hy@SaveLastskip
  \label{thmt@@#1@data}%
  \Hy@RestoreLastskip
  \egroup
}%

seems to work. Maybe thmtools can define its own versions of \Hy@SaveLastskip and \Hy@RestoreLastskip?

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

1 participant