Math & ScienceI'm tired of typing \left and \right all the time...

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

I'm tired of typing \left and \right all the time...

Post by Singularity »

...so I tried to create new commands

Code: Select all

\newcommand{\(}{\left(}
\newcommand{\)}{\right(}
at the top of my document. But, as you expected, that was already defined. Is there a way around that which a non-expert can implement?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

I'm tired of typing \left and \right all the time...

Post by Johannes_B »

You could do something more robust. Remember to give your own commands unique names.

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\newcommand{\lpar}{\left(}
\newcommand{\rpar}{\right)}
\begin{document}
\[ 
\lpar x+y \rpar^4 = x^4  +  4 x^3y  +  6 x^2 y^2  + 
4 x y^3  +  y^4
\]
\[ \lpar\frac{x+1}{\frac{1}{x}}\rpar \]
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

I'm tired of typing \left and \right all the time...

Post by mas »

For friends/colleagues who mention this sort of problem, I always suggest to use the editor provided shortcuts to cut down the typing.

I also suggest that you take a look at the package commath to ease typing material with different brackets et al. The following code looks simpler:

Code: Select all

\documentclass{article}

\usepackage{mathtools}
\usepackage{commath}

\begin{document}
\[
\del{x+y}^4 = x^4  +  4 x^3y  +  6 x^2 y^2  +
4 x y^3  +  y^4
\]

\[ \del{\frac{x+1}{\frac{1}{x}}} \]

\end{document}

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

I'm tired of typing \left and \right all the time...

Post by Johannes_B »

Package physics could be helpful as well.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

I'm tired of typing \left and \right all the time...

Post by mas »

Johannes_B wrote:Package physics could be helpful as well.
Thanks. That is a very handy set of macros :-)

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply