This question is related to Question: linebreak in macros, however it is not asking for the same information and I separated it out:

In my documents, I make use of commands like the following:

\newcommand{\AND}[2]{\left(#1 \vee #2 \right)}

The advantages are quite obvious:

  • better readable code
  • no forgotten parenthesis
  • the possibility to redefine later without searching each occurrence
  • always the correct number of arguments
  • uniform design

The only disadvantage that I found so far is, that the whole environment doesn't work any more when its contents becomes to large, i.e. in nested occurrences of the command.

So here's the question: Is the way I do it considered to be best practice? If yes, how should I handle the problem mentioned above? If no, should I type all the mathematics code explicitely, i.e. without shortcut macros? How could I keep at least some of the advantages?

  • Using commands like your \AND requires you get used to prefix notation rather than infix notation, which some might find confusing. Also, this could lead to many extraneous parentheses.
    – Seamus
    Jan 15, 2013 at 14:15

3 Answers 3


In general it is a good idea to define macros related to the mathematical (or other) constructs that you use. the benefits are as you give. The main disadvantage is that unless you choose the macro names well or (even:-) document your definitions then someone else (or you 10 years later) can not so easily read the TeX code and know what it does.

For the particular case it may be that your macro is too simple to meet your requiremsnts and you need something like




where the optional argument forces it to use \bigl \bigr instead of \left \right which gives more control over the sizing and may allow line breaking in some cases. Or some other markup depending on the requirements. (Hard to know without seeing an example of a case where you are not happy with your original command, so I don't actually offer a definition here.)

  • Apart from daleif's answer, the exact thing you say can be achieved with this answer.
    – Manuel
    Jan 15, 2013 at 16:22
  • @David My Problem starts as soon, as automatic linebreaks are involved. So putting the whole thing into a small \parbox and inserting long arguments into it leads to not breaking properly. Actually I don't want to control the size of the parens, but I want to have it determined automatically. This however doesn't work with a macro that can do linebreaks.
    – grackkle
    Jan 16, 2013 at 14:55
  • 1
    a primitive tex \left\right makes a box like \hbox or \mvox, so you can not linebreak within That is why I suggested the option of manualy choosing delimiter size and allowing breaks (although the syntax us perhaps not so good for a term that may break) or you could look at breqn package which redefines \left and \right (and everything else) and so alows automatic line breaking Jan 16, 2013 at 16:09
  • the info about \left\right creating a box is new to me and helped a lot. I already had a look at breqn, but I tested it only inside of an align* which seems to prevent linebreaks anyways. I'll have another look into it.
    – grackkle
    Jan 16, 2013 at 18:27
  • Don't mix breqn with ams or other math environments it nees to stand aone and hav efull control over the entire formula Jan 16, 2013 at 19:23

Here's how I would to it

\DeclarePairedDelimiterX\AND[2]{(}{)}{#1\vee #2}

Then \AND*... equal your version and \AND[\big]... equal Davids solution

  • Good so far, but the non-starred version doesn't resize the parens as I'd like, while the starred version doesn't support line-breaks. Any idea, how to reach both?
    – grackkle
    Jan 16, 2013 at 15:00
  • 1
    You cannot, a \left ... \right pair cannot be broken, it has to measure the stuff in between...
    – daleif
    Jan 17, 2013 at 9:05

Macros can definitely be a good way to go, however I choose my editors to do all that work for me. For example,


With the vim-latex suite, typing (( creates \left( (cursor placed here) \right)<++> where you just press C-j to 'jump' to the next <++>.


With Auctex (my editor/plugin of choice), you type C-c C-m left <RET> ( <RET and it produces: \left( cursor placed here \right)

These have the added advantage of they will be always readable. There are loads of guides out there, and probably more editors to choose from. (I wrote a blog post comparing them at http://opensourceawesomesauce.blogspot.co.uk/2012/10/latex-editors-emacs-vs-vim.html.)

  • 1
    This may work in the case of parenthesis, but your solution comes with the drawback that later redifinitions are not possible. Also longer and more complex definitions are not suitable with your solution. However, using keyboard shortcuts and powerful editors is a must have for TeX anyways.
    – grackkle
    Jan 16, 2013 at 14:19
  • True, although with vim-latex, complex solutions are really easy to wire into the shortcuts. Auctex has the capability but my lisp isn't good enough to do them. But you're right, neither of these give the flexibility of changing it afterward. Jan 16, 2013 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .