# Using different fonts for theorem label in header

In the accepted answer to Put current theorem-like item's name/number in header it's shown how to put the label of the current theorem in the header. Is there a way to use two different fonts for the 'Theorem x.y' and the '(optional theorem name)' parts of the theorem label. I'd like to use \scshape for the former and \normalfont for the latter. I tried messing with the code but I get errors, specifically

Argument of \@begintheorem has an extra}.


when I try to use \textsc, and

Missing control sequence inserted.


when I use \scshape or \normalfont.

• If you post a MWE, or at least what you have, we’d be better able to figure out what’s going on. – Davislor Feb 8 '19 at 20:29

In a comment to my answer to the original question, the OP explained that this question actually asks how to have the references to the theorem titles included in the running heads atop pages use the same fonts as those used in the titles themselves (that is, in the text body). I think that this is a typographic mistake, and that changes in the fonts of the running heads should be avoided, but anyway…

The following compilable example shows how to patch the code of my other answer so as to obtain what the OP asks for:

\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,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{}
\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{****************************************}
\newcommand*\my@direct@mark[3]{%
\myMark{% <<< MODIFIED
\thmname{#1}%
\thmnumber{\thmname{\ }#2}%
\thmnote{\ {\the\thm@notefont (#3)}}% as above
}%
}%
}
\newcommand*\my@swapped@mark[3]{%
\myMark{% <<< MODIFIED
\thmnumber{#2}%
\thmname{\thmnumber{\ }#1}%
\thmnote{\ {\the\thm@notefont (#3)}}%
}%
}%
}
\patchcmd{\@begintheorem}{% search for:
}{% replace with:
\thm@swap\my@swapped@mark\my@direct@mark{#1}{#2}{#3}%
}{% 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
}}{}{}
\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
%     \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}

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

% \lipsum[85-96]

\end{document}


Note that \the\thm@headfont and \the\thm@notefont should reflect the state of affairs at the time at which the theorem title is typest, so they must be expanded when the \myMark command is issued.

Use the \newtheoremstyle command of amsthm. There are other options, including the ntheorem package.

\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}


Any font package that (unlike the default) contains bold small caps will work for this example. It would also be possible to load fontspec (and even to create fake-bold small caps for Latin Modern if you want).