以下环境引入了缩进,我想避免这种情况。使用{%
和}%
没有帮助。
\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
\begin{document}
\NewDocumentEnvironment{wvPzz}{O{orange}mmo}
{%
\smallskip%
\IfNoValueTF {#4}
{%
#2 \ #3 \hspace{\parindent}%
}%
{%
#2 \ #3 \ (#4)%
\smallskip \par%
}%
\color{#1}%
}%
{%
\smallskip%
}
Some Text Here
\begin{wvPzz}{aa}{bb}
Some Text
\end{wvPzz}
Write Something
\begin{wvPzz}{aa}{bb}[cc]
Some Text
\end{wvPzz}
Write Something
\begin{wvPzz}[blue]{aa}{bb}
Some Text
\end{wvPzz}
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
\end{document}
答案1
不清楚您想要抑制哪些缩进,因为环境定义没有添加任何缩进,只有正常的段落缩进。但请注意,您应该在垂直模式下添加垂直跳过,因此前面是\par
或空白行。我添加了\noindent
所以(正如您在评论中而不是在问题中问的那样)aa
与divisors
\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
\begin{document}
\NewDocumentEnvironment{wvPzz}{O{orange}mmo}
{% par before smallskip
\smallskip%
\IfNoValueTF {#4}
{%
% this is very weird, after #3, you get a word space, parindent???
% and thenpossibly a word space or paragraph break or possibly no space
% then the text from the body of the environment.
\noindent #2 \ #3 \hspace{\parindent}%
}%
{%
% as above the behaviour after (#4) is somewhat variable
#2 \ #3 \ (#4)%
% \par before \smallskip, not after
\par\smallskip
}%
\color{#1}%
}%
{%
% par (or blank line) before smallskip
\par
\smallskip%
}
Some Text Here
\begin{wvPzz}{aa}{bb}
Some Text
\end{wvPzz}
Write Something
\begin{wvPzz}{aa}{bb}[cc]
Some Text
\end{wvPzz}
Write Something
\begin{wvPzz}[blue]{aa}{bb}
Some Text
\end{wvPzz}
A prime number is a natural number greater than 1 that has no positive
divisors other than 1 and itself.
\end{document}