在新环境中重新定义命令 [英] Redefining commands in a new environment

查看:59
本文介绍了在新环境中重新定义命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个问题:

  1. LaTeX是否允许一个人(重新)定义\newenvironment中的命令?我试过在之前声明中使用\renewcommand\newcommand\def,但无济于事.

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆