在页眉中使用不同的字体作为定理标签

在页眉中使用不同的字体作为定理标签

在接受的答案中将当前定理类项目的名称/编号放在标题中它显示了如何将当前定理的标签放在标题中。有没有办法对定理标签的“定理 xy”和“(可选定理名称)”部分使用两种不同的字体。我想\scshape对前者和\normalfont后者使用。我尝试弄乱代码,但出现了错误,具体来说

Argument of \@begintheorem has an extra}.

当我尝试使用时\textsc

Missing control sequence inserted.

当我使用\scshape或时\normalfont

答案1

一条评论我对原始问题的回答,原帖者解释说,这个问题实际上是在问如何让页眉中的定理标题引用使用与标题本身(即正文)相同的字体。我认为这是一个印刷错误,应该避免更改页眉的字体,但无论如何……

以下可编译示例显示了如何修补我的其他答案的代码以获得 OP 所要求的内容:

\documentclass[a4paper,twoside]{article}
\usepackage[T1]{fontenc} % Not necessary, but recommended.
\usepackage{etoolbox}

\usepackage{amsthm} % comment or uncomment as you prefer
\usepackage{amsfonts} % for "\mathbb"

\usepackage{fancyhdr}
\usepackage{lipsum}

\fancyhf{}
\fancyhead[RO]{(Normal font?)\ \thepage} % show that the font for the rest
\fancyhead[LE]{\thepage\ (Normal font?)} % of the header is not affected
% \fancyhead[LE,RO]{\thepage} % this one should be used for the real thing
\fancyhead[RE,LO]{\myBotmark} % "RE" just for testing purposes
\pagestyle{fancy}

\newtheorem{theorem}{Theorem}[section] % or "[chapter]", or whatever
\newtheorem{lemma}  {Lemma}  [section]

% A little trick to make this example work both with amsthm and without it;
% once you've made your choice, you do not need this code.
\makeatletter
    \@ifdefinable\IfAmsThm{}
    \@ifpackageloaded{amsthm}{
        \let \IfAmsThm = \@firstoftwo
    }{
        \let \IfAmsThm = \@secondoftwo
    }
\makeatother

\IfAmsThm{
    \newtheorem*{spclaim}{Special Claim}
    \swapnumbers
    \theoremstyle{definition}
}{}

\newtheorem{defin}{Definition}[section]



%%%%%%%% BEGIN WIZARDRY %%%%%%%%

\makeatletter

\@ifdefinable\@my@claim@mark{\newmarks\@my@claim@mark}
\newcommand*\myMark[1]{% <<< MODIFIED
    \begingroup
        \let\label\relax \let\index\relax \let\glossary\relax
        \let\protect\@unexpandable@protect
        \marks\@my@claim@mark{#1}%
    \endgroup
}
\newcommand*\myBotmark{\botmarks\@my@claim@mark}

\typeout{****************************************}
\@ifpackageloaded{amsthm}{\iftrue}{\iffalse}
    \newcommand*\my@direct@mark[3]{%
        \myMark{% <<< MODIFIED
            {\the\thm@headfont % _should_ be expanded
                \thmname{#1}%
                \thmnumber{\thmname{\ }#2}%
                \thmnote{\ {\the\thm@notefont (#3)}}% as above
            }%
        }%
    }
    \newcommand*\my@swapped@mark[3]{%
        \myMark{% <<< MODIFIED
            {\the\thm@headfont
                \thmnumber{#2}%
                \thmname{\thmnumber{\ }#1}%
                \thmnote{\ {\the\thm@notefont (#3)}}%
            }%
        }%
    }
    \patchcmd{\@begintheorem}{% search for:
        \thm@swap\swappedhead\thmhead % more specific than before
    }{% replace with:
        \thm@swap\my@swapped@mark\my@direct@mark{#1}{#2}{#3}%
        \thm@swap\swappedhead\thmhead
    }{% execute if succeeded:
        \typeout{>>> Made patch specific for amsthm.}
    }{% execute if failed:
        \typeout{>>> Patch specific for amsthm FAILED!}
    }
\else
    \apptocmd{\@begintheorem}     {\myMark{#1\ #2}\ignorespaces}{}{}
    \apptocmd{\@opargbegintheorem}{\myMark{%
                    #1\ #2%
                    \ (#3)% comment this line to leave Mickey Mouse out
                    \ignorespaces
                }}{}{}
    \typeout{>>> Made generic patch.}
\fi
\typeout{****************************************}

\makeatother

%%%%%%%%  END WIZARDRY  %%%%%%%%



\begin{document}

\section{First section}

\lipsum[1]

\begin{theorem}
    This is the first theorem of the first section.
\end{theorem}

\lipsum[2]

\begin{theorem}
    This is the second theorem of the first section.
\end{theorem}

\begin{theorem}[Donald Duck and~$\mathbb{Q}$]
    The third theorem of the first section.
\end{theorem}

\IfAmsThm{
    \begin{spclaim}
        This is a special claim.
    \end{spclaim}
}{}

% \begingroup
%     \showboxbreadth = 1000
%     \showboxdepth = 10
%     \tracingonline = 1
%     \showlists
% \endgroup

\lipsum[3-16]

\begin{theorem}
    This is the fourth theorem of the first section.
\end{theorem}

\begin{defin}[Something new]
    This is the first definition of the first section.
\end{defin}

\begin{defin}
    This is the second definition of the first section.
\end{defin}

\lipsum[17]

\begin{lemma}
    This is the first lemma of the first section.
\end{lemma}

\lipsum[18]

\begin{theorem}
    This is the fifth theorem of the first section.
\end{theorem}

\lipsum[19-20]

\begin{lemma}[Uncle Scrooge and~$\mathbb{R}$]
    The second lemma of the first section.
\end{lemma}

\lipsum[21-32]

\begin{theorem}
    This is the sixth theorem of the first section.
\end{theorem}

\lipsum[33-36]

\begin{theorem}
    This is the seventh theorem of the first section.
\end{theorem}

\begin{lemma}
    This is the third lemma of the first section.
\end{lemma}

\begin{theorem}[Mickey Mouse and~$\mathbb{C}$]
    The eighth theorem of the first section.
\end{theorem}

\lipsum[37-40]

\begin{theorem}
    This is the ninth theorem of the first section.
\end{theorem}

\lipsum[41-48]

\begin{defin}
    This is the third definition of the first section.
\end{defin}

\lipsum[49-64]

\begin{theorem}[The last one]
    This is the tenth theorem of the first section.
\end{theorem}

\lipsum[65-80]

\begin{lemma}
    This is the fourth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the fifth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the sixth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the seventh lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the eighth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the ninth lemma of the first section.
\end{lemma}

\begin{lemma}[Deep breath]
    This is the tenth lemma of the first section.
\end{lemma}

\lipsum[81-84]

\begin{lemma}
    This is the eleventh lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the twelfth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the thirteenth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the fourteenth lemma of the first section.
\end{lemma}

\begin{lemma}
    This is the fifteenth lemma of the first section.
\end{lemma}

\begin{lemma}[Hexadecimal deep breath]
    This is the sixteenth lemma of the first section.
\end{lemma}

% \lipsum[85-96]

\end{document}

注意\the\thm@headfont\the\thm@notefont应该反映定理标题类型化时的事态,因此在\myMark发出命令时必须扩展它们。

答案2

使用命令\newtheoremstyleamsthm。还有其他选择,包括ntheorem套餐。

\documentclass[varwidth, preview]{standalone}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amsthm}
\usepackage{newpxtext, newpxmath}

\newtheorem{axiom}{Axiom}

\newtheoremstyle{funkytheorem}%
{}{}%
{\itshape}{}%
{\bfseries\scshape}{.}%
{ }%
{\thmname{#1}\thmnumber{ #2}\thmnote{{\normalfont\ (#3)}}}

\theoremstyle{funkytheorem}

\newtheorem{colaxiom}[axiom]{Corollary}

\begin{document}
\begin{axiom}
\(A = A\).
\end{axiom}

\begin{colaxiom}[Corollary Axiom]
\(B = B\).
\end{colaxiom}
\end{document}

定理样式示例

任何包含粗体小写字母(不同于默认字体)的字体包都适用于此示例。也可以加载fontspec(如果需要,甚至可以为 Latin Modern 创建仿粗体小写字母)。

相关内容