1

I have the following code suggested by David Carlisle. I do not see the theorem head with a bold typeface. I would also like to add some vertical spacing after the theorem head, rather than just a newline.

How do I add a colour for the Theorem string and section number?


    \newtheoremstyle{naiad}%
    {3pt}         % space measure above theorem
    {3pt}         % space measure below theorem
    {\itshape}    % name of font for body of theorem
    {}            % space measure to indent
    {\bfseries}   % name of head font
    {}            % punctuation between head and body
    {\newline}    % space after theorem head
    {}            % 

    \theoremstyle{naiad}
    \newtheorem{theorem}{Theorem}[section]
2
  • Hi, @Ephram, and welcome to TeX.SE. Please read about MWE. Post, always when you can, a complete compilable source, so people here know which packages you are using and can also copy, paste and reproduce your results faster. For example, in your case I guessed your were using amsthm, since I know the syntax you presented, but it may not be true in other contexts or may even not work if another some other package is interfering.
    – FHZ
    Commented Apr 24, 2022 at 2:17
  • 1
    Thank you. You were right, I am using amsthm.
    – Veak
    Commented Apr 24, 2022 at 11:24

1 Answer 1

0

The following MWE shows how to edit \thmname, \thmnumber and \thmnote in order to change font typeface and color. Colors are just inserted as example, please don't take them as a good aesthetics.

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}

\newtheoremstyle{myExample}% name of the style to be used
{} % {\topsep}% measure of space to leave above the theorem. E.g.: 3pt
{} % {\topsep}% measure of space to leave below the theorem. E.g.: 3pt
{\itshape} % {\itshape}% name of font to use in the body of the theorem
{} % {0pt}% measure of space to indent
{} %{\bfseries}% name of head font
{.}% punctuation between head and body
{ }% space after theorem head; " " = normal interword space
{{\thmname{\textbf{\textit{#1}}}} \textcolor{orange}{\textbf{\thmnumber{#2}}}\thmnote{ \textit{\texttt{\textsf{({#3})}}}}}

\theoremstyle{myExample}
\newtheorem{example}{\textcolor[rgb]{0.00,0.50,0.00}{Example}}[section]

\newtheoremstyle{naiad}%
{3pt}         % space measure above theorem
{3pt}         % space measure below theorem
{\itshape}    % name of font for body of theorem
{}            % space measure to indent
{\bfseries}   % name of head font
{}            % punctuation between head and body
{\newline}    % space after theorem head
{{\thmname{\textbf{\textit{#1}}}} \textcolor{purple}{\textbf{\thmnumber{#2}}}\thmnote{ \textsf{({#3})}}}            % 

\theoremstyle{naiad}
\newtheorem{theorem}{\textcolor[rgb]{0.30,0.30,1}{Theorem}}[section]

\begin{document}
\section{S1}
\begin{example}[Name of the example]
  Text of the example
\end{example}

\begin{theorem}[Name of the theorem]
  Text of the theorem
\end{theorem}

\section{S2}
\begin{example}[Name of the example]
Text of the example
\end{example}

\begin{theorem}[Name of the theorem]
Text of the theorem
\end{theorem}

\end{document}

enter image description here

You may see some more examples using amsthm here. There might be also interesting taking a look at thmtools.

1
  • It is really good.
    – Veak
    Commented Apr 24, 2022 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .