定理名称未进入辅助

定理名称未进入辅助

我已经发布一个问题. egreg 回答。我将他的解决方案应用到我的演讲中。它奏效了。然后我尝试将它应用到我的论文中,在那里我使用了参考文献,我意识到定理名称由于某种原因没有出现在论文中aux。这是一个例子。

\documentclass[notheorems,slidescentered]{beamer}
\usepackage{amsthm,thmtools,xparse,lipsum,hyperref}

\protected\def\thistheoremname{}
\declaretheoremstyle[
  spaceabove=\topsep, spacebelow=\topsep,
  headfont=\normalfont\bfseries,
  bodyfont=\normalfont\itshape,
  postheadspace=.5em,
  name={\thistheoremname},
  numbered=no,
  headpunct=.]
{mystyle}
\declaretheorem[style=mystyle]{@thmattr}
\NewDocumentEnvironment{teorspec}{O{Teorema}mo}
 {\def\thistheoremname{#1 #2}
 \IfValueTF{#3}
     {\begin{@thmattr}[label=#3]}
     {\begin{@thmattr}}}
 {\end{@thmattr}}

\begin{document}
\begin{frame}
\begin{teorspec}[Principio]{di D'Alembert}[thm:spec:Dalemb]
Foobar.
\end{teorspec}
\end{frame}

\begin{frame}
\lipsum[1]
\end{frame}

\begin{frame}
Abbiamo poco fa enunciato il \nameref{thm:spec:Dalemb}, o principio del vincolo liscio.
\end{frame}
\end{document}

现在我意识到演示文稿不太适合引用,但我懒得更改课程或创建自己的 MWE,所以我只是对 egreg 的答案代码进行了必要的编辑。正如您所看到的,如果您编译,引用不起作用:

在此处输入图片描述

生成的aux文本如下:

\relax 
\providecommand\hyper@newdestlabel[2]{}
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
\global\let\oldcontentsline\contentsline
\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global\let\oldnewlabel\newlabel
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\ifx\hyper@anchor\@undefined
\let\contentsline\oldcontentsline
\let\newlabel\oldnewlabel
\fi}
\fi}
\global\let\hyper@last\relax 
\gdef\HyperFirstAtBeginDocument#1{#1}
\providecommand\HyField@AuxAddToFields[1]{}
\providecommand\HyField@AuxAddToCoFields[2]{}
\@writefile{toc}{\beamer@endinputifotherversion {3.33pt}}
\@writefile{nav}{\beamer@endinputifotherversion {3.33pt}}
\newlabel{thm:spec:Dalemb}{{}{1}{}{Doc-Start}{}}
\@writefile{snm}{\beamer@slide {thm:spec:Dalemb}{1}}
\@writefile{loe}{\contentsline {@thmattr}{\numberline {\let \autodot \@empty }Principio di D'Alembert}}
\@writefile{nav}{\headcommand {\slideentry {0}{0}{1}{1/1}{}{0}}}
\@writefile{nav}{\headcommand {\beamer@framepages {1}{1}}}
\@writefile{nav}{\headcommand {\slideentry {0}{0}{2}{2/2}{}{0}}}
\@writefile{nav}{\headcommand {\beamer@framepages {2}{2}}}
\@writefile{nav}{\headcommand {\slideentry {0}{0}{3}{3/3}{}{0}}}
\@writefile{nav}{\headcommand {\beamer@framepages {3}{3}}}
\@writefile{nav}{\headcommand {\beamer@partpages {1}{3}}}
\@writefile{nav}{\headcommand {\beamer@subsectionpages {1}{3}}}
\@writefile{nav}{\headcommand {\beamer@sectionpages {1}{3}}}
\@writefile{nav}{\headcommand {\beamer@documentpages {3}}}
\@writefile{nav}{\headcommand {\def \inserttotalframenumber {3}}}

具体来说,标签行\newlabel{thm:spec:Dalemb}{{}{1}{}{Doc-Start}{}}有一个空行,{}而不是正确的行{Principio di D'Alembert}。为什么会发生这种情况?我该如何修复?

答案1

通常\label由最后一个 \refstepcounter 设置,但由于超目标部分不起作用,所以它并不重要。

\documentclass[slidescentered]{beamer}
\usepackage{amsthm,thmtools,xparse,lipsum,hyperref}

\makeatletter
\protected\def\thistheoremname{}
\declaretheoremstyle[
  spaceabove=\topsep, spacebelow=\topsep,
  headfont=\normalfont\bfseries,
  bodyfont=\normalfont\itshape,
  postheadspace=.5em,
  name={\thistheoremname},
  numbered=no,
  headpunct=.]
{mystyle}
\declaretheorem[style=mystyle]{@thmattr}
\NewDocumentEnvironment{teorspec}{O{Teorema}mo}
 {\def\thistheoremname{#1 #2}%
 \refstepcounter{theorem}%
 \edef\@currentlabelname{#2}%
 \label{#3}%
 \begin{@thmattr}}
 {\end{@thmattr}}
\makeatother

\begin{document}
\begin{frame}
\begin{teorspec}[Principio]{di D'Alembert}[thm:spec:Dalemb]
Foobar.
\end{teorspec}
\end{frame}

\begin{frame}
\lipsum[1]
\end{frame}

\begin{frame}
Abbiamo poco fa enunciato il \nameref{thm:spec:Dalemb}, o principio del vincolo liscio.
\end{frame}
\end{document}

相关内容