在新环境中重新定义命令 [英] Redefining commands in a new environment
问题描述
两个问题:
-
LaTeX是否允许一个人(重新)定义
\newenvironment
中的命令?我试过在之前声明中使用\renewcommand
,\newcommand
和\def
,但无济于事.
Does LaTeX allow one to (re)define commands within a
\newenvironment
? I've tried using\renewcommand
,\newcommand
and\def
in the before declaration but to no avail.
在创建新列表环境时,如何重新定义\item
?
How would one redefine \item
when creating a new list environment?
我已经使用\newenvironment
从头开始创建了一种新型的列表环境,同时为每个令牌使用了另一个令牌而不是\item
,但是我真的很想通过使用\list
并重新定义\item
来保持事物的一致性.
I've created a new type of list environment from scratch using \newenvironment
while using another token instead of \item
for each but I'd really like to keep things consistent by using \list
and redefining \item
.
推荐答案
可以;如果不查看代码,很难知道出了什么问题.为了回答您的两个问题,请查看是否有帮助:
Sure; it's hard to know what went wrong without seeing your code. As an answer to your two questions, see if this helps:
\documentclass{article}
\begin{document}
\newenvironment{myitemize}{%
\begin{list}{}{}% whatever you want the list to be
\let\olditem\item
\renewcommand\item{\olditem ITEM: }
}{%
\end{list}
}
\begin{myitemize}
\item one \item two
\end{myitemize}
\end{document}
这篇关于在新环境中重新定义命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!