1

I usually define some command of the kind

\newcommand{\paren}[#1]{\left(#1\right)}

to make the use of parentheses more agile. Now, if in the body of my document I do this

\begin{align}
z = \paren{y\\+z}
\end{align}

I get a long list of complaints on the last line of the align environment, while I would expect the same output as for the following code,

\begin{align}
z = \left(y\\+z\right)
\end{align}

Anybody can let me know how to make this sort of parentheses commands robust over line breaks?

\documentclass{article}
\usepackage{amsmath}

\newcommand{\paren}[1]{\left(#1\right)}



\begin{document}


% This works, but I don't like it.
\begin{align}
z = \left(y\right.\\
\left.+z\right)
\end{align}

% This is lovely, but does not work.
%\begin{align}
%z = \paren{y\\+z}
%\end{align}

% No complaints, of course, if the line break is removed
\begin{align}
z = \paren{y+z}
\end{align}

\end{document}
8
  • 2
    (1) Welcome, (2) in general using \left...\right every time is a bad idea. For one, it is unbreakable. Plus \left(\\\right) hides \\ from align, so it will never work. I'd say that in general such an approach is not worth it.
    – daleif
    Jan 13, 2015 at 9:41
  • 2
    Welcome to TeX.SX! Your first example does not work and I would be very surprised if it does for you. If you use some ` \\ ` in between your parentheses, you have to end the first line by \right. and start the next line with \left.
    – LaRiFaRi
    Jan 13, 2015 at 9:41
  • 2
    And the \left A \right. \\ \left. B \right approach may be faulty too, if A and B are not the same size. Manually scaling fences that are to be broken is almost always better.
    – daleif
    Jan 13, 2015 at 9:44
  • @Antonio, try replacing y by \frac{1}{2} and you will see the problem with the approach
    – daleif
    Jan 13, 2015 at 9:46
  • 2
    See the postings Is it ever bad to use \left and \right? and “(” or “\left(” parentheses? for a more in-depth examinaton of why it's not good practice to use \left( and \right) everywhere.
    – Mico
    Jan 13, 2015 at 9:48

2 Answers 2

4

As mentioned in the comments it is not recommended, and such a solution will make the code much less readable.

That being said, it can be done. This use a trick suggested by Sebastien Gouezel cited from the mathtools manual

\documentclass[a4paper]{memoir}
\usepackage{amsmath}

\newcommand\MTkillspecial[1]{% helper macro
  \bgroup
  \catcode`\&=9
  \let\\\relax%
  \scantokens{#1}%
  \egroup
}

\newcommand\paren[1]{
  \left(\vphantom{\MTkillspecial{#1}}\kern-\nulldelimiterspace\right.
  #1
  \left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#1}}\right)
}


\begin{document}

\begin{align*}
  A  = {} & \paren{ \frac12 \\ & +3 } 
\end{align*}


\end{document}

I would still manually scale fences in such a situation, as in

\begin{align*}
  A = {} & \biggl( \frac12
  \\
  & +3 \biggr)
\end{align*}

which in my opinion is a lot more readable.

0

The package mathtools offers a command \DeclarePairedDelimiter to be put in the preamble.

\documentclass[a4paper]{minimal}
\usepackage{amsmath}
\usepackage{mathtools}

\DeclarePairedDelimiter{\paren}{\lparen}{\rparen}

\begin{document}

\begin{equation}
\begin{aligned}
\paren{a+\\
b = 3
}
\end{aligned}
\end{equation}

However, one needs to manually resize the delimiter.

\begin{equation}
\begin{aligned}
\paren[\bigg]{a+\\
b = 3
}
\end{aligned}
\end{equation}

\end{document}

You must log in to answer this question.

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