I am using thmtools to create exercise environments. The format I am looking for is:
- The exercise number, in bold
- a period and space
- If the exercise note is set (with the
name) key, the note in bold and another space - the exercise body
The trouble I'm having is that I'm getting some extra horizontal spacing when the note is set. Also, if there is an empty block of options, more extra space is inserted. Here is the MWE:
\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[
headfont=\bfseries,
notefont=\bfseries,
headformat={\NUMBER.\if\NOTE\ \else \NOTE\fi},
headpunct={},
notebraces={}{},
numbered=yes
]{exercise}
\declaretheorem[style=exercise]{exercise}
\begin{document}
\begin{exercise}foo\end{exercise}
\begin{exercise}[
] bar
\end{exercise}
\begin{exercise}[name=Baz]baz\end{exercise}
\end{document}

Without the headformat key set I don't get any of these extra spaces, but them of course it's not the format I want. So how do I set headformat to get what I want without the extra space?

\show\NOTEto yourheadformatdefinition (somewhere) and see what\NOTElooks like. It doesn't just contain the note, but is comprised of an\if..\fi, so your test wouldn't work. – Werner Jun 17 '14 at 15:32namekey. So the second case is functionally equivalent toname={ }. Or something like that. – Matthew Leingang Jun 17 '14 at 15:52