tufte-book:thmtools 定理环境中的脚注产生错误

tufte-book:thmtools 定理环境中的脚注产生错误

我无法将该tufte-book类应用于我的文档(以前的book类)。目前,我正在尝试寻找如何在环境中使用脚注的解决方案thmtools。PdfLaTeX 给了我以下错误:

Missing number, treated as zero. ...\footnote{...}
Illegal unit of measure (pt inserted). ...\footnote{...}
Class tufte-book Error:

thmtools定理在序言中定义如下:

\usepackage{tikz}    
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{needspace}
\usepackage[T1]{fontenc}


\declaretheoremstyle[
spaceabove=\topsep, 
spacebelow=\topsep,
numberwithin=chapter,
headfont=\normalfont\bfseries,
notefont=\normalfont\scshape, 
notebraces={$\lbrack$}{$\rbrack$},
postheadhook={\textcolor{gray}{\rule[.6ex]{\linewidth}{0.4pt}}\\},
bodyfont=\normalfont\itshape,
mdframed={
    backgroundcolor=gray, 
    linecolor=gray, 
    innertopmargin=6pt,
    roundcorner=5pt, 
    innerbottommargin=6pt, 
    skipabove=\parsep, 
    skipbelow=\parsep },
postheadspace=\newline
]{theorembreak}

\declaretheorem[style=theorembreak,name=Theorem]{theorem}
\AtBeginEnvironment{theorem}{\Needspace{10\baselineskip}}

文中的定理如下:

\begin{theorem}[Theorem]
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.\footnote{This is a footnote within a theorem.}
\end{theorem}

问题在于脚注。没有脚注的定理也可以正常工作。如何解决这个问题?

完整的 MWE 以及利用tufte-book类 (找到这里)如下:

\documentclass{tufte-book}

% For graphics / images
\usepackage{graphicx}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
\graphicspath{{graphics/}}

% The fancyvrb package lets us customize the formatting of verbatim
% environments.  We use a slightly smaller font.
\usepackage{fancyvrb}
\fvset{fontsize=\normalsize}

%%
% Prints argument within hanging parentheses (i.e., parentheses that take
% up no horizontal space).  Useful in tabular environments.
\newcommand{\hangp}[1]{\makebox[0pt][r]{(}#1\makebox[0pt][l]{)}}

%%
% Prints an asterisk that takes up no horizontal space.
% Useful in tabular environments.
\newcommand{\hangstar}{\makebox[0pt][l]{*}}

%%
% Prints a trailing space in a smart way.
\usepackage{xspace}


% Prints an epigraph and speaker in sans serif, all-caps type.
\newcommand{\openepigraph}[2]{%
  %\sffamily\fontsize{14}{16}\selectfont
  \begin{fullwidth}
  \sffamily\large
  \begin{doublespace}
  \noindent\allcaps{#1}\\% epigraph
  \noindent\allcaps{#2}% author
  \end{doublespace}
  \end{fullwidth}
}

% Inserts a blank page
\newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage}

\usepackage{units}

% Typesets the font size, leading, and measure in the form of 10/12x26 pc.
\newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}}

% Macros for typesetting the documentation
\newcommand{\hlred}[1]{\textcolor{Maroon}{#1}}% prints in red
\newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}}
\newcommand{\hairsp}{\hspace{1pt}}% hair space
\newcommand{\hquad}{\hskip0.5em\relax}% half quad space
\newcommand{\TODO}{\textcolor{red}{\bf TODO!}\xspace}
\newcommand{\na}{\quad--}% used in tables for N/A cells
\providecommand{\XeLaTeX}{X\lower.5ex\hbox{\kern-0.15em\reflectbox{E}}\kern-0.1em\LaTeX}
\newcommand{\tXeLaTeX}{\XeLaTeX\index{XeLaTeX@\protect\XeLaTeX}}
% \index{\texttt{\textbackslash xyz}@\hangleft{\texttt{\textbackslash}}\texttt{xyz}}
\newcommand{\tuftebs}{\symbol{'134}}% a backslash in tt type in OT1/T1
\newcommand{\doccmdnoindex}[2][]{\texttt{\tuftebs#2}}% command name -- adds backslash automatically (and doesn't add cmd to the index)
\newcommand{\doccmddef}[2][]{%
  \hlred{\texttt{\tuftebs#2}}\label{cmd:#2}%
  \ifthenelse{\isempty{#1}}%
    {% add the command to the index
      \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name
    }%
    {% add the command and package to the index
      \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name
      \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name
    }%
}% command name -- adds backslash automatically
\newcommand{\doccmd}[2][]{%
  \texttt{\tuftebs#2}%
  \ifthenelse{\isempty{#1}}%
    {% add the command to the index
      \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name
    }%
    {% add the command and package to the index
      \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name
      \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name
    }%
}% command name -- adds backslash automatically
\newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath{\rangle}}% optional command argument
\newcommand{\docarg}[1]{\textrm{\textit{#1}}}% (required) command argument
\newenvironment{docspec}{\begin{quotation}\ttfamily\parskip0pt\parindent0pt\ignorespaces}{\end{quotation}}% command specification environment
\newcommand{\docenv}[1]{\texttt{#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name
\newcommand{\docenvdef}[1]{\hlred{\texttt{#1}}\label{env:#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name
\newcommand{\docpkg}[1]{\texttt{#1}\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}}% package name
\newcommand{\doccls}[1]{\texttt{#1}}% document class name
\newcommand{\docclsopt}[1]{\texttt{#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name
\newcommand{\docclsoptdef}[1]{\hlred{\texttt{#1}}\label{clsopt:#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name defined
\newcommand{\docmsg}[2]{\bigskip\begin{fullwidth}\noindent\ttfamily#1\end{fullwidth}\medskip\par\noindent#2}
\newcommand{\docfilehook}[2]{\texttt{#1}\index{file hooks!#2}\index{#1@\texttt{#1}}}
\newcommand{\doccounter}[1]{\texttt{#1}\index{#1 counter@\texttt{#1} counter}}

% Generates the index
\usepackage{makeidx}
\makeindex

\usepackage{tikz}  
\usepackage{amsthm}  
\usepackage{thmtools}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{needspace}
\usepackage[T1]{fontenc}



\declaretheoremstyle[
spaceabove=\topsep, 
spacebelow=\topsep,
numberwithin=chapter,
headfont=\normalfont\bfseries,
notefont=\normalfont\scshape, 
notebraces={$\lbrack$}{$\rbrack$},
postheadhook={\textcolor{gray}{\rule[.6ex]{\linewidth}{0.4pt}}\\},
bodyfont=\normalfont\itshape,
mdframed={
    backgroundcolor=gray, 
    linecolor=gray, 
    innertopmargin=6pt,
    roundcorner=5pt, 
    innerbottommargin=6pt, 
    skipabove=\parsep, 
    skipbelow=\parsep },
postheadspace=\newline
]{theorembreak}

\declaretheorem[style=theorembreak,name=Theorem]{theorem}
\AtBeginEnvironment{theorem}{\Needspace{10\baselineskip}}


\begin{document}


\mainmatter
\chapter{Introduction}

\begin{theorem}[Theorem]
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.\footnote{This is a footnote within a theorem.}
\end{theorem}


\end{document}

答案1

这算是一种答案,尽管看起来是负面的。你的定理本质上是一个mdframed环境,而 tufte 类重新定义\footnote\sidenote。所以你的例子可以归结为

\documentclass{tufte-book}
\usepackage{mdframed}
\begin{document}
\begin{mdframed}
  Some text.
  \sidenote{This is a side note.}
\end{mdframed}
\end{document}

这给出了错误

! Missing number, treated as zero.
<to be read again> 
                   ]
l.6   \sidenote{This is a side note.}

根据答案在 mdframed 环境中使用 sidenotes

该命令\sidenote等于\marginpar\marginnote不允许在表格或框中使用。所以您不能使用它们。

这个答案是四年前的,也许不再适用,并且有一个解决方案。

相关内容