0

I have been using \newcommand and \renewcommand for defining simple commands like the typical

\newcommand{\R}{\mathbb{R}}

But now I wonder if I can renew other types of commands. What I want to do is to create a simple command like

\env

to substitute longer commands like

\begin{my environment}

(And for example \eenv for \end{my environment})

Au101
  • 10,278
D1X
  • 291
  • ...why don't you try it? ;-) – Rmano Feb 23 '16 at 20:37
  • You don't wanna use the quote markdown > you should use code sample (highlight code and hit Ctrl+k or the button that looks like { }, alternatively you can add four spaces at the start of each line). Yes you can do this. It's generally not considered a good idea, the environment structure is there for code readability and trouble shooting and these abbreviations are known to break when used for align http://tex.stackexchange.com/questions/100138/what-is-wrong-with-defining-bal-as-beginalign. It'd be much better to get a good editor that can automate this – Au101 Feb 23 '16 at 20:44
  • 1
    The answer to your question is that you can define whatever you want, except for a command that starts with \end.., but whether it'll work is something altogether different. While using \env...\eenv may work in general, there are some instances where it won't. Those instances depend on whether TeX is expecting an explicit \end{env} form or not. This is typically the case with verbatim, and listings, and filecontents, and align, and there could be others. – Werner Feb 23 '16 at 21:05
  • 2
    apart from the examples that Werner gives where it will not work, even where it does work it is a bad idea, the distinction between environments and commands is a fundamental design choice in the design of latex and using latex but then disrupting its syntax in this way just leads to confusion, both to humans and to software such as syntax checkers and syntax highlighting and editors that can collapse or move environments etc – David Carlisle Feb 23 '16 at 21:30
  • And moreover, this kind of definition is not useful at all. My editor will automatically expand a "fig"+tab at the start of the line to a full figure environment --- which is handier than defining a command. In general, use a command only to define a logical higher level command, not to save typing --- that last is a task for your editor, – Rmano Feb 23 '16 at 22:15

0 Answers0