0

I'm trying to renew \[ and \] in such a way that it is the same of writing

\begin{equation*}
\begin{split}

\end{split} \end{equation*}

I remember a question in TEX SE that contained an attempt in something similar but I can't find it anymore. My current attempt is

\renewcommand{\[}{\begin{equation*}\begin{split}}
\renewcommand{\]}{\end{split}\end{equation*}}

But I get many errors. Is this considered a bad practice in general? Why?

Bernard
  • 271,350
Fral
  • 79
  • 2
    It's the same problem as https://tex.stackexchange.com/q/100138/82917. split is looking for a literal \end{split}. – campa Jul 24 '22 at 07:35
  • 6
    as campa says techically it fails as split needs to see \end{split} but it is a bad idea to redefine core latex commands in this way. LaTeX syntax is not just a hack to get ink on paper, it forms a language of communication of technical documents. After any such redefinition, fragments of your document look like latex but do not match its rules or any of the millions of documents describing latex syntax. In general speaking a common language is better than speaking a laguage with only one user. Any reasonable editor would allow you to add the full form in a few keystrokes. – David Carlisle Jul 24 '22 at 09:59
  • 3
    Rather than redefine core LaTeX commands and risk triggering nasty edge effects, I'd suggest configuring your editor to typeset the four lines that you want automatically. Every civilized editor should have some tool to do that, from macro to code snippets or advanced completion features. – Miyase Jul 24 '22 at 10:47
  • Thanks to everybody. @Miyase currently I'm using overleaf and I'm not aware of such a feature, do you know some editors capable of it? Maybe VScode with some LaTeX extension? – Fral Jul 24 '22 at 14:36
  • @Fral I did that sort of thing with TeXstudio before, and with VS Code now, and I know that many other editors can do it too. – Miyase Jul 24 '22 at 17:39

1 Answers1

2

As it has been mentioned in the comments, you can use a workaround from: What is wrong with defining \bal as \begin{align}?, so that

\documentclass{article}
\usepackage{amsmath}

\def[#1]{\begin{equation}\begin{split}#1\end{split}\end{equation}}

\begin{document}

[ 1+1&=2\ x&=y+z ]

\end{document}

enter image description here

antshar
  • 4,238
  • 9
  • 30