答案1
您可以使用\@hangfrom
,但不能通过\par
这种方式在该环境内使用令牌(或两个连续的新行)。
如果您愿意的话,您可能还想改变它的定义\maggicmd
(或者根本不使用它)。
\documentclass[]{article}
\usepackage{amsmath}
\makeatletter
\newlength\maggi@indent
\setlength\maggi@indent{1cm}
\newcommand*\MAggi{\PackageError{maggi}{Don't use me outside of the maggi environment}{}}
\newcommand*\maGgi{\PackageError{maggi}{Don't use me outside of the maggi environment}{}}
\newcommand*\magGi{\PackageError{maggi}{Don't use me outside of the maggi environment}{}}
\newcommand*\maggI{\PackageError{maggi}{Don't use me outside of the maggi environment}{}}
\newenvironment{maggi}
{%
\def\MAggi{\par\bigskip\@hangfrom{\makebox[\maggi@indent][l]{Ma:}}}%
\def\maGgi{\par\medskip\@hangfrom{\kern\maggi@indent\makebox[\maggi@indent][l]{G:}}}%
\let\magGi\maGgi
\def\maggI{\par\medskip\@hangfrom{\makebox[\maggi@indent][l]{I:}}}%
}
{%
\par\bigskip
% the following will supress paragraph indentation if you don't put an empty
% line after \end{maggi}
\@endpetrue
}
\makeatother
\newcommand\maggicmd[1]{\operatorname{\mathsf{\MakeUppercase{#1}}}}
\usepackage{duckuments}
\begin{document}
\blindduck[-]
\begin{maggi}
\MAggi I want to find the intersection between $f$ and $g$
\maGgi $Y_1 = x^2$\\
$Y_2 = 4$\\
$\maggicmd{intersect}(Y_1, Y_2, \text{Guess next to }-2)$\\
$\maggicmd{intersect}(Y_1, Y_2, \text{Guess next to }2)$
\magGi $(-2|4)$\\
$(2|4)$
\maggI The graphs of $f$ and $g$ have two intersections. One in $(-2|4)$ and
one in $(2|4)$.
\end{maggi}
\blindduck[-]
\end{document}