Latex 中的自定义 MaGGI 宏

Latex 中的自定义 MaGGI 宏

在我学校使用计算器时,我们必须用特定的方式记录。这被称为 MaGGI 概念,由四个部分组成:主题思想,G图形计算器输入,G图形计算器输出,以及解释。它的特别之处在于意图。两个 G 必须用“一个制表符”来抵消。

在此处输入图片描述

我尝试使用该软件包构建类似的东西enumerate,但无法使其工作。我该如何为此创建自定义宏?

例如:

\begin{maggi}
\ma LOREM
\g IPSUM
\g DOLOR
\i SIT
\end{maggi}

答案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}

在此处输入图片描述

相关内容