2

I have a problem using the parskip and thmtools packages. I want to use the boxes provided by thmtools to frame my theorems lemmas etc. The one I'm interested in is the thmbox=M box but as soon as the parskip package is loaded everything goes wrong. The reason I don't want to give up on parskip is that I don't like automatic indentation and it's very practical to space out paragraphs.

Let me illustrate this with codes and images.

Without parskip loaded:

\documentclass[12pt]{article}
\usepackage{amsmath}
%\usepackage{parskip}

\usepackage{amsthm,thmtools}

\declaretheorem[thmbox=M]{theorem}

\begin{document}

\begin{theorem}[without parskip]
blabla bla bla,
\[\sum_{k=1}^n k^2 = \dfrac{n(n+1)(2n+1)}{6}.\]
\end{theorem}

\end{document}

Which gives the following result,

enter image description here

With parskip loaded:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{parskip}

\usepackage{amsthm,thmtools}

\declaretheorem[thmbox=M]{theorem}

\begin{document}

\begin{theorem}[with parskip]
blabla bla bla,
\[\sum_{k=1}^n k^2 = \dfrac{n(n+1)(2n+1)}{6}.\]
\end{theorem}

\end{document}

resulting in a mess,

enter image description here

Does any one has a solution to fix this?

Thanks a lot!

1 Answer 1

5

thmbox initializes the value of option leftmargin to \parindent. Thus if thmbox is loaded after parskip, leftmargin is set to 0pt and the problem reproduces:

\documentclass[12pt]{article}
\usepackage{parskip}
\usepackage{thmbox}

\begin{document}
\begin{thmbox}[M]{The title}
  Some text, some more text, asufficient amount to get afull box with several lines.
\end{thmbox}

% with `article` class option 12pt, \parindent defaults to 1.5em
\begin{thmbox}[M,leftmargin=1.5em]{The title}
  Some text, some more text, asufficient amount to get afull box with several lines.
\end{thmbox}
\end{document}

thmbox example

For direct use of thmbox, loading it before parskip works.

The situation is a little bit messer for thmtools: it loads thmbox only when \declaretheorem option thmbox={<thmbox options>} is used for the first time. It's still feasible to load parskip after all such \declaretheorem usages, but here I suggest to load parskip in a late hook used after the whole preamble and just before begindocument: begindocument/before (It's equivalent to \AtEndPreamble from etoolbox package.)

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm,thmtools}
\usepackage[pass,showframe]{geometry}

\declaretheorem[thmbox={M,leftmargin=1.5em}]{theorem}

\AddToHook{begindocument/before}{%
  \usepackage{parskip}%
}

\begin{document}
\begin{theorem}[with parskip]
  blabla bla bla,
  \[\sum_{k=1}^n k^2 = \dfrac{n(n+1)(2n+1)}{6}.\]
\end{theorem}
\end{document}

thmtools example, using hook "begindocument/before"

One can also backup the value of \parindent before loading parskip, and then pass that value to thmbox option leftmargin, like

\newlength{\origparindent}
\setlength{\origparindent}{\parindent}
\usepackage{parskip}
...
\declaretheorem{thmbox={M,leftmargin=\origparindent}}{theorem}
1
  • 1
    Thanks a lot, I understand a lot better now, and I think I'll be able to do what I have in mind with all your solutions! Jun 13, 2023 at 19:43

You must log in to answer this question.

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