为什么新定义的环境末尾自带空格?

发布于 2022-06-29 23:38:46

我使用了如下代码:

\CJKsetecglue{}
\punctstyle{banjiao}
\newcounter{proof}%用于控制proof换行的环境
\newenvironment{proof}
    {\setcounter{proof}{60}\vspace{0em}\par\setlength{\parindent}{-0.5em}\setlength{\leftskip}{5.5em}\hspace{-2.8em}$proof$:}
    {\hfill $\square$\par\vspace{0em}\setcounter{proof}{67}\setlength{\parindent}{-0.5em}\setlength{\leftskip}{0.5em}}
\newenvironment{subsize}
    {\vspace{0em}\par\addtocounter{proof}{5}\setlength{\parindent}{-0.5em}\setlength{\leftskip}{\theproof pt}}
    {\par\vspace{0em}\addtocounter{proof}{-5}\setlength{\parindent}{-0.5em}\setlength{\leftskip}{\theproof pt}}

当我输入了这样的代码时:

\begin{proof}
    使用数学\\归纳法证明:\par
    使用数学\\归纳法证明:
    \begin{subsize}
        对$n=3$,成立
    \end{subsize}
\end{proof}

其产生效果如下
image.png

但我想要实现:
前后无间距以使得悬挂缩进可以实现。

这该怎么解决?

查看更多

关注者
1
被浏览
1.7k
1 个回答
Sagittarius Rover
Sagittarius Rover 2025-04-22
我要成为Typst糕手/(ㄒoㄒ)/~~

我觉得你不应该用计数器proof以及\theproof的值来控制长度。

另外我没看懂『前后无间距以使得悬挂缩进可以实现』,以及subsize是想实现什么...

如果你需要『悬挂缩进』,其实latex2e是有类似的quote环境的:

image.png

%article.cls
\newenvironment{verse}
               {\let\\\@centercr
                \list{}{\itemsep      \z@
                        \itemindent   -1.5em%
                        \listparindent\itemindent
                        \rightmargin  \leftmargin
                        \advance\leftmargin 1.5em}%
                \item\relax}
               {\endlist}
\newenvironment{quotation}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item\relax}
               {\endlist}
\newenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item\relax}
               {\endlist}

另外,代码要给完整...同时最好详细描述proof以及subsize想达到的预期效果示意图。

撰写答案

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览