3

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
\def\thmhead@plain#1#2#3{%
  \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
  \thmnote{ {\the\thm@notefont\textbf{#3}}}}
\let\thmhead\thmhead@plain
\makeatother

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

\makeatletter
\def\th@definition{%
  \thm@notefont{}% same as heading font
  \normalfont % body font
}
\makeatother

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

Finally I tried,

\makeatletter
\def\thmhead@definition#1#2#3{%
  \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}%
  \thmnote{ {\the\thm@notefont\textbf{#3}}}}
\let\thmhead\thmhead@plain
\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
3

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:

enter image description here

\documentclass{article}

\usepackage{amsthm}

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

\makeatletter
\def\thmhead@plain#1#2#3{%
  \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
  }
\let\thmhead\thmhead@plain
\makeatother

\begin{document}

\section{A section}

\subsection{A subsection}

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

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

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.