muzimuzhi / thmtools

New home for LaTeX package bundle thmtools
LaTeX Project Public License v1.3c
16 stars 3 forks source link

something went wrong when using `\declaretheoremstyle` and `\declaretheorem` in LaTeX3 #26

Closed xkwxdyy closed 2 years ago

xkwxdyy commented 2 years ago

I want to remove the . after the head, i.e. make headpunct = {}, but the key headpunct is only available in \declaretheoremstyle, so I used it to create a new style without ., but something goes wrong with it when I used it in LaTeX3, here is a MWE:

\documentclass{ctexbook}
\usepackage{amsthm}
\usepackage{thmtools}
\ExplSyntaxOn
\declaretheoremstyle
  [
    spaceabove = 3pt,
    spacebelow = 3pt,
    headfont = \bfseries,
    bodyfont = \normalfont,
    headpunct = {},
    postheadspace = { },
    headindent = {},
    notefont = { \fontseries \mddefault \upshape }
  ]{ccnustyle}
\cs_new:Npn \__xdyymath_declare_theorem_with_counter_within:n #1
  {
    \declaretheorem
      [
        style = ccnustyle,
        name =  \clist_item:nn {#1} {1} ,
        refname = \clist_item:nn {#1} {2} ,
        within = \clist_item:nn {#1} {3} ,
      ]
      { \clist_item:nn {#1} {4} }
  }
\cs_new:Npn \__xdyymath_declare_theorem_with_counter_sibling:n #1
  {
    \declaretheorem
      [
        style = ccnustyle ,
        name =  \clist_item:nn {#1} {1} ,
        refname = \clist_item:nn {#1} {2} ,
        sibling = \clist_item:nn {#1} {3} ,
      ]
      { \clist_item:nn {#1} {4} }
  }
\clist_map_function:nN
  {
    { 定理, 定理, chapter, theorem }
  }\__xdyymath_declare_theorem_with_counter_within:n

\clist_map_function:nN
  {
    { 定义, 定义, theorem, definition }
  }\__xdyymath_declare_theorem_with_counter_sibling:n
\ExplSyntaxOff

\begin{document}
\begin{definition}[limit]
  test
\end{definition}
\end{document}

And the fatal message is

Missing number, treated as zero.
<to be read again> 

Illegal unit of measure (pt inserted).
<to be read again> 

I don't know what's wrong with it.

xkwxdyy commented 2 years ago

https://tex.stackexchange.com/questions/635396/something-went-wrong-when-using-declaretheoremstyle-and-declaretheorem-in

It had been solved.

muzimuzhi commented 2 years ago

I've added an answer on TeX-SX.

Short answer: With amsthm + thmtools, postheadspace accepts a length or a space or \newline. Within \ExplSyntaxOn ... \ExplySyntaxOff, one should use postheadspace={~} to pass a space.

xkwxdyy commented 2 years ago

I've added an answer on TeX-SX.

Short answer: With amsthm + thmtools, postheadspace accepts a length or a space or \newline. Within \ExplSyntaxOn ... \ExplySyntaxOff, one should use postheadspace={~} to pass a space.

Thanks so much. I got it.