我正在用乳胶准备一份文档,我需要定义一个新环境,如下所示:
当代码为:
\begin{IF}
the sum of $a$, $b$, and $c$ is 10,\\
the product of $a$, $b$, and $c$ is 14,\\
the sum of squares of $a$, $b$, and $c$ is 54;
\end{IF}
显示如下:
IF: the sum of a, b and c is 10,
the product of a, b, and c is 14;
the sum of squares of a, b, and c is 54;
注意:
- 正文第一句以关键字“IF”开头,即同一行。
- 正文中这三句话是左对齐的。
你能帮我定义这个 IF 环境吗?非常感谢!!
答案1
这是一个使用列表的选项,借助enumitem
:
\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\newlength\mylen
\AtBeginDocument{\settowidth\mylen{IF:~}}
\newlist{MIF}{description}{1}
\setlist[MIF,1]{leftmargin=*,labelsep=0pt,itemindent=-\mylen}
\newenvironment{IF}
{\begin{MIF}\item[\textnormal{IF:~}]}
{\end{MIF}}
\begin{document}
\lipsum[4]
\begin{IF}
the sum of $a$, $b$, and $c$ is 10,\\
the product of $a$, $b$, and $c$ is 14,\\
the sum of squares of $a$, $b$, and $c$ is 54;
\end{IF}
\lipsum[4]
\end{document}
结果: