3

How do I remove the unwanted space before the optional argument (set here) and after the theorem-like environment's name (Intuitive idea--- here)?

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
  headfont= \sffamily\bfseries,
  headpunct={\sffamily\bfseries.},
  postheadspace=0.5em,
  notefont=\sffamily\bfseries,
  bodyfont=\normalfont,
  notebraces={}{},
  numbered=no
]{discuss}

\theoremstyle{discuss}

\makeatletter
%
\declaretheorem[
  name=Intuitive idea---,
  preheadhook=\renewcommand{\thmt@space}{},
  numbered=no
]{intuit}
%
\makeatother

\begin{document}

%\lipsum[1]

\begin{intuit}[set]
A set is a collection of objects.
\end{intuit}

\end{document}

Unwanted space before optional argument

As shown, I tried the method, given at How can I remove the space before a custom theorem-like environment header?, of using preheadhook=\renewcommand{\thmt@space}{}. But that still leaves the space.

2
  • There was a post, now disappeared, that just used name=Intuitive idea---\ignorespaces, in the \declaretheorem. What's wrong with that?
    – murray
    Commented Jun 16, 2018 at 19:50
  • It was my post. I deleted it after the @egreg's solution, which looks like more correct.
    – Sigur
    Commented Jun 16, 2018 at 19:54

1 Answer 1

4

You can use headformat:

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\makeatletter
\declaretheoremstyle[
  headfont=\sffamily\bfseries,
  headpunct=.,
  postheadspace=0.5em,
  notefont=\sffamily\bfseries,
  bodyfont=\normalfont,
  notebraces={}{},
  numbered=no,
  headformat=\NAME---\NOTE,
  preheadhook=\renewcommand\thmt@space{},
]{discuss}
\makeatother

\declaretheorem[
  style=discuss,
  name=Intuitive idea,
  numbered=no
]{intuit}

\begin{document}

\lipsum[1]

\begin{intuit}[set]
A set is a collection of objects.
\end{intuit}

\end{document}

enter image description here

On the other hand, if the argument is always present, it should be a mandatory argument (so that an optional one is still possible).

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\declaretheoremstyle[
  headfont=\sffamily\bfseries,
  headpunct=.,
  postheadspace=0.5em,
  notefont=\sffamily\bfseries,
  bodyfont=\normalfont,
  numbered=no,
]{discuss}

\declaretheorem[
  style=discuss,
  name=\protect\INTUIT,
  numbered=no
]{innerintuit}
\newenvironment{intuit}[1]
 {\newcommand\INTUIT{Intuitive idea---#1}\innerintuit}
 {\endinnerintuit}

\begin{document}

\lipsum[1]

\begin{intuit}{set}
A set is a collection of objects.
\end{intuit}


\begin{intuit}{set}[Cantor]
A set is a collection of objects.
\end{intuit}

\end{document}

enter image description here

6
  • Without the note the dash is still there. Is it possible to insert if and only if there is a note?
    – Sigur
    Commented Jun 16, 2018 at 19:51
  • @Sigur: For my own purposes, I'll always have an optional argument with this theorem-like environment.
    – murray
    Commented Jun 16, 2018 at 19:54
  • @murray, so, no problem anymore. go ahead with the nice solution. Regards.
    – Sigur
    Commented Jun 16, 2018 at 19:56
  • @murray I added a different implementation: if the optional argument is required, it should be a mandatory one.
    – egreg
    Commented Jun 16, 2018 at 20:03
  • @egreg: For my purposes, I'll never have both the required optional argument and an additional, actually optional one. But your additional implementation is nonetheless very instructive (the sort of thing I don't get out of just perusing the thmtools documentation)!
    – murray
    Commented Jun 16, 2018 at 20:07

You must log in to answer this question.

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