4

I have to use the thmtools package to style my theorems, lemmas, remarks etc.

Unfortunately, I noticed that when I give an optional name to a remark for instance this name is in normal font, but the dot after it is in bold and it stands out as not nice IMPO!

I want to keep in bold font the name remark and the dot when there is no optional name but I want the dot in normal font when there is one optional name. How do I do it?

Here is my MWE:

\documentclass{amsbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{thmtools}

\declaretheoremstyle[spaceabove=6pt plus 0pt minus 2pt, spacebelow=0pt plus 0pt minus 2pt, headfont=\bfseries, bodyfont=\normalfont, postheadspace=5pt plus 1pt minus 1pt]{myremstyle}

\declaretheorem[style=myremstyle,name=Remarque,numbered=no]{rem}

\begin{document}
\begin{rem}[not quite nice effect]
\end{rem}
\end{document}
6
  • 1
    Related: tex.stackexchange.com/questions/252391/…
    – egreg
    Jul 8, 2015 at 22:12
  • @egreg You are absolutely right to point at my own previous question ! The answer given there worked well. Unfortunately here in this document I am using the package thmtools. Is it possible to tweak it the same way or should I get rid of it ?
    – brunoh
    Jul 8, 2015 at 22:19
  • @egreg I had to use to this package because I needed the listoftheorem function. So if I get rid of it, I have to do the macro myself ...
    – brunoh
    Jul 8, 2015 at 22:21
  • Have you considered using the ntheorem package and using that package's \listtheorems command?
    – Mico
    Jul 8, 2015 at 22:29
  • @mico Yes. But some incompatibilities happened with amsbook class. So I invested lots of time tweaking my lists with thmtools. I really do not want to change and learn the details again ... But thanks for the suggestion.
    – brunoh
    Jul 8, 2015 at 22:32

2 Answers 2

2

For reasons I don't understand, the note is typeset in a group. Anyway, the workaround is not pretty, because you need to specify headformat in all styles you define.

\documentclass{amsbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{thmtools}
\usepackage{etoolbox}

\makeatletter
% don't typeset the note in a group, so the punctuation inherits
% the font specification of the note
\patchcmd{\thmt@setheadstyle}
 {\bgroup\thmt@space}
 {\thmt@space}
 {}{}
\patchcmd{\thmt@setheadstyle}
 {\egroup\fi}
 {\fi}
 {}{}
\makeatother

\declaretheoremstyle[
  spaceabove=6pt plus 0pt minus 2pt,
  spacebelow=0pt plus 0pt minus 2pt,
  headfont=\bfseries,
  bodyfont=\normalfont,
  postheadspace=5pt plus 1pt minus 1pt,
  headformat=\NAME\NOTE,
]{myremstyle}

\declaretheoremstyle[
  spaceabove=6pt plus 0pt minus 2pt,
  spacebelow=0pt plus 0pt minus 2pt,
  headfont=\bfseries,
  bodyfont=\normalfont,
  postheadspace=5pt plus 1pt minus 1pt,
  headformat=\NAME\ \NUMBER\NOTE,
]{myfoostyle}

\declaretheorem[
  style=myremstyle,
  name=Remarque,
  numbered=no
]{rem}

\declaretheorem[
  style=myfoostyle,
  name=Foo,
]{foo}

\begin{document}

\begin{rem}[nice effect]
Some remark
\end{rem}
\begin{rem}
Some remark
\end{rem}
\begin{foo}[nice effect]
Some foo
\end{foo}
\begin{foo}
Some foo
\end{foo}
\end{document}

enter image description here

2

You can use headformat with \NAME, \NUMBER, \NOTE, and apply \normalfont if there is annotation:

\documentclass{amsbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{thmtools}

\declaretheoremstyle[
  spaceabove=6pt plus 0pt minus 2pt, 
  spacebelow=0pt plus 0pt minus 2pt, 
  headfont=\bfseries, 
  bodyfont=\normalfont,
  postheadspace=5pt plus 1pt minus 1pt,
  headformat={\NAME~\NUMBER\NOTE\if\empty\relax\else\normalfont\fi}
]{myremstyle}
\declaretheorem[style=myremstyle,name=Remarque,numbered=no]{rem}

\begin{document}
\begin{rem}[quite nice effect]
test text.
\end{rem}
\begin{rem}
test text.
\end{rem}
\end{document}

The result:

enter image description here

8
  • \NOTE is never empty; its definition is \if=<note>=...\fi. And, anyway, \if\NOTE\empty is conceptually wrong. The code works but not for the reason you are thinking to.
    – egreg
    Jul 8, 2015 at 22:39
  • @egreg Hmmm. That's what I thought and it explains why my attempts with \detokenize failed, but then why is my code with \empty working? What is the conceptually good approach? Jul 8, 2015 at 22:40
  • Remove \empty and it will work the same.
    – egreg
    Jul 8, 2015 at 22:41
  • @egreg You're right. Let me think on what is going on. Jul 8, 2015 at 22:42
  • @egreg I give up. I don't quite understand why my code works. I guess you do know, so would you please explain what's going on? Jul 8, 2015 at 22:45

You must log in to answer this question.

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