# How to change font on definition's optional title, but not on theorem's optional titles?

My preamble is the following:

\newtheorem{teo}{Theorem}[subsection]
\theoremstyle{definition}
\newtheorem{defi}{Definition}[subsection]


The default is set so

\begin{defi}[Some defi]
\end{defi}

\begin{teo}[Some theorem]
\end{teo}


Outputs both titles [Some xxx] between parentheses. I want to change only the definition title to bold and remove its parentheses. I have tried the following:

\makeatletter
\thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
\thmnote{ {\the\thm@notefont\textbf{#3}}}}
\makeatother


Which correctly changes the title font to bold and removes parentheses, but in all cases. I have also tried,

\makeatletter
\def\th@definition{%
\normalfont % body font
}
\makeatother


Which leaves theorem titles as they are, changes definition title font to bold but keeps parentheses.

Finally I tried,

\makeatletter
\thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
\thmnote{ {\the\thm@notefont\textbf{#3}}}}
\makeatother


Which doesn't work at all. Any idea on how to proceed?

• Welcome to TeX SX! I suppose your preamble also loads amsthm. You should take a look at the thmtools package, which provides powerful tools to customise the layout of theorem-like structures, and cooperates with amsthm as well as ntheorem. – Bernard Jun 9 '17 at 13:32

The following code uses \pdfstrcmp to condition on whether \thmhead is called as a definition or a theorem. That way you can format things to suit your needs based on the environment:

\documentclass{article}

\usepackage{amsthm}

\newtheorem{teo}{Theorem}[subsection]
\theoremstyle{definition}
\newtheorem{defi}{Definition}[subsection]

\makeatletter
\thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
\ifnum\pdfstrcmp{#1}{Definition}=0
\thmnote{ {\the\thm@notefont\textbf{#3}}}%
\else
~\thmnote{{\the\thm@notefont (#3)}}%
\fi
}
\makeatother

\begin{document}

\section{A section}

\subsection{A subsection}

\begin{defi}[Some defi]
\end{defi}

\begin{teo}[Some theorem]
\end{teo}

\end{document}