0

When I looked for a solution to auto-resize pairs of delimiters without using \left and \right I found this topic: auto-resizing parenthesis in math formulas. It works as expected but it can't be used inside e.g align due to & and \\. Is there any way to make it work with align-like enviromnents?

I have tried to solve this issue in dumb way using some workaround from mathtools manual:

\documentclass[a4paper,12pt]{article}

\usepackage{mathtools,unicode-math,xparse}

\newcommand*\autoop{\lrparen(}
\newcommand*\autoob{\lrbrack[}

\AtBeginDocument{
    \mathcode`( 32768
    \mathcode`[ 32768
    \begingroup
        \lccode`\~`(
        \lowercase{%
    \endgroup
    \let~\autoop}
    \begingroup
        \lccode`\~`[
        \lowercase{%
    \endgroup
    \let~\autoob}
}

\delimiterfactor 1001

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

\NewDocumentCommand\lrparen{d()}{
\mathopen{\left(\vphantom{\MTkillspecial{#1}}\kern-\nulldelimiterspace\right.}
#1
\mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#1}}\right)}}

\NewDocumentCommand\lrbrack{o}{
\mathopen{\left[\vphantom{\MTkillspecial{#1}}\kern-\nulldelimiterspace\right.}
#1
\mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#1}}\right]}}

\begin{document}
    \begin{align*}
        [[ ( a,\\ b ) ]]
    \end{align*}
\end{document}

but it fix only line break problem. Last answer in mentioned topic use some sort of queue or stack, so I wonder if this problem could be solved by expl3 or luatex because I don't see the way to rewrite original answer to play with align and friends.

Bernard
  • 271,350
Serafiel
  • 139
  • even without align it is almost always better to use manually chosen sizes with \biggl( rather than \left( so there is very little call for this. breqn may be the nearest thing to this that is available out of the box – David Carlisle Mar 12 '20 at 10:19
  • @DavidCarlisle does breqn actually do that? Isn't it nath that could do autoscaling of everything, but then again nath is incompatible with almost everything. – daleif Mar 12 '20 at 10:56
  • @daleif er I'd need to check:-) If you are asking then possibly not.... – David Carlisle Mar 12 '20 at 10:56
  • what do you mean by fix only line break problem ? doesn't your scantokens make & safe during the measuring part? You don't give an example using & – David Carlisle Mar 12 '20 at 10:58
  • @DavidCarlisle In original topic we can't use \\. In my solution \\ works but & throw errors. Try [[ ( &a,\\ &b ) ]] inside align. – Serafiel Mar 12 '20 at 11:12

0 Answers0