LaTeX forum ⇒ Math & ScienceI'm tired of typing \left and \right all the time... Topic is solved

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

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

Postby Singularity » Mon Apr 21, 2014 9:37 am

...so I tried to create new commands
  1. \newcommand{\(}{\left(}
  2. \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?

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Apr 21, 2014 1:53 pm

You could do something more robust. Remember to give your own commands unique names.
  1. \documentclass{article}
  2. \usepackage{mathtools}
  3. \newcommand{\lpar}{\left(}
  4. \newcommand{\rpar}{\right)}
  5. \begin{document}
  6. \[
  7. \lpar x+y \rpar^4 = x^4 + 4 x^3y + 6 x^2 y^2 +
  8. 4 x y^3 + y^4
  9. \]
  10. \[ \lpar\frac{x+1}{\frac{1}{x}}\rpar \]
  11. \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: 201
Joined: Thu Dec 04, 2008 4:39 am

Postby mas » Tue Apr 22, 2014 3:04 am

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:
  1. \documentclass{article}
  2.  
  3. \usepackage{mathtools}
  4. \usepackage{commath}
  5.  
  6. \begin{document}
  7. \[
  8. \del{x+y}^4 = x^4 + 4 x^3y + 6 x^2 y^2 +
  9. 4 x y^3 + y^4
  10. \]
  11.  
  12. \[ \del{\frac{x+1}{\frac{1}{x}}} \]
  13.  
  14. \end{document}

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

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Apr 22, 2014 8:47 am

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: 201
Joined: Thu Dec 04, 2008 4:39 am

Postby mas » Tue Apr 22, 2014 1:44 pm

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


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 2 guests