我想创建一个可以如下使用的命令环境:
\begin{myenv}
\command1
text paragraph 1
\command2
text paragraph 2
\end{myenv}
翻译过来就是:
\begin{someenv}
\begin{env1}
text paragraph 1
\end{env1}
\begin{env2}
text paragraph 2
\end{env2}
\end{someenv}
其中someenv
,env1
和env2
是 LaTex 中的一些现有环境。
我怎样才能做到这一点?
答案1
可以使用分隔宏来完成这样的事情\par
(memoir
与此无关,它只是我通常的基类)
\documentclass[a4paper]{memoir}
% note the contents of \mymacro is limited to a single
% paragraph. Because we ue the blank line (paragraph end) as a delimiter
\def\mymacro#1\par{\begin{center}#1\end{center}}
\newenvironment{test}{\par\noindent\hrule\par}{\par\noindent\hrule\par}
\begin{document}
\begin{test}
\mymacro
Some long text
\mymacro
Some egen longer text
% above blank line is very important
\end{test}
\end{document}