环境中hook失效并报错“Missing number”

发布于 2024-12-18 21:47:08
\documentclass[zihao=5,twoside]{ctexart}
% \usepackage[margin=1cm]{geometry}
\usepackage[]{zhlipsum}
\NewDocumentEnvironment{hangingindent}{}
{%
  \par\begingroup%
  \setlength\parindent{0bp}%
  \AddToHook{para/begin}[myppkg]{\hangafter1\hangindent30bp\noindent}%
}%
{\RemoveFromHook{para/begin}[myppkg]\endgroup\par}%

\begin{document}
{\par
\setlength\parindent{0bp}
\AddToHook{para/begin}[mypkg]{\hangafter1\hangindent30bp\noindent}
\zhlipsum[1]
\RemoveFromHook{para/begin}[mypkg]\par
}

\begin{hangindent}
\zhlipsum[1]
\end{hangindent}
\end{document}

报错信息:

./env.tex:21: Missing number, treated as zero.
<to be read again> 
                   \xparse function is not expandable 
l.21 \zhlipsum
              [1]
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

./env.tex:21: Illegal unit of measure (pt inserted).
<to be read again> 
                   \xparse function is not expandable 
l.21 \zhlipsum
              [1]
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)

image.png

查看更多

关注者
0
被浏览
85
1 个回答
泪过无痕
泪过无痕 3天前
这家伙很懒,什么也没写!

笔误
image.png

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览