输出 \left(...\right) 括号的有效大小

输出 \left(...\right) 括号的有效大小

我试图在文档中删除\left(and ,同时保持括号的最合适大小。但是,可能有几十次(或更多)出现这种情况,我想避免无数次地浏览文档,对每个操作尝试,等,并重复编译。所以我想我可以重新定义以输出警告来指示\right)\big\Big\left(

  1. 我正在使用它,但不应该使用它,
  2. 当前构造的有效尺寸\left(...\right)易于替换。

我知道mathtools\delimsize,但我这个只能与一起使用\DeclarePairedDelimiter

这可能吗?

一些已经对我有帮助的东西:在哪里\left实际\right定义?

答案1

让文本编辑器将所有出现的 更改\left\xleft\yleft,具体取决于您喜欢这两种方法中的哪一种。然后,每次\left调用 a 时,都会在构造的左侧\fbox显示一个。$\big#1\Big#1\bigg#1\Bigg#1$

这是让您采取行动的标志。您可以直观地查看 4 个“大”构造中是否有合适的大小,然后对其进行编辑,\xleft或者\yleft将其更改为合适的大分隔符,或者\left如果它们都不起作用,则将其改回。

\xleft和之间的唯一区别\yleft\yleft\smash。这在嵌套发生\fbox时很有用,否则会改变外部 的自然大小。 的缺点是它允许发生重叠,这可能会有点令人困惑,直到做出解决方案。\left\fbox\left\yleft

\documentclass{article}
\def\xleft#1#2\right{
  \fbox{$\big#1\Big#1\bigg#1\Bigg#1$}\left#1#2\right}
\def\yleft#1#2\right{
  \smash{\fbox{$\big#1\Big#1\bigg#1\Bigg#1$}}\left#1#2\right}
\begin{document}
Here is the \verb|\yleft| method which smashes the test box.
\[
y = \yleft( x^2 + 3\right)
\]
And now for the next test:
\[
y = \yleft(\frac{a}{b}\right)
\]
Finally:
\[
y = 3\yleft(\frac{\yleft( x^2 + 3\right)}{b}\right)
\]
Here is the \verb|\xleft| method which does not smash the test box.
\[
y = \xleft( x^2 + 3\right)
\]
And now for the next test:
\[
y = \xleft(\frac{a}{b}\right)
\]
Finally:
\[
y = 3\xleft(\frac{\xleft( x^2 + 3\right)}{b}\right)
\]
\end{document}

在此处输入图片描述


对于基于维度的方法,\basesizes在文档开头调用以查看 、 和 的垂直维度\big\Big然后\bigg\Bigg所有更改\left\zleft以显示给定构造所需的大小。

\documentclass{article}
\usepackage{scalerel}
\def\zleft#1#2\right{
  \smash{\ThisStyle{\setbox0=\hbox{$\SavedStyle\left#1#2\right.$}%
  \edef\tmp{\the\dimexpr\ht0+\dp0\relax}%
  \fbox{\expandafter\truncate\expandafter{\tmp}}}}%
  \left#1#2\right}
\newcommand\truncate[1]{\truncateaux#1\relax}
\def\truncateaux#1.#2\relax{#1pt}
\newcommand\basesizes{%
  \noindent big: \setbox0=\hbox{\big(}\the\dimexpr\ht0+\dp0\relax\par
  \noindent Big: \setbox0=\hbox{\Big(}\the\dimexpr\ht0+\dp0\relax\par
  \noindent bigg: \setbox0=\hbox{\bigg(}\the\dimexpr\ht0+\dp0\relax\par
  \noindent Bigg: \setbox0=\hbox{\Bigg(}\the\dimexpr\ht0+\dp0\relax\par
}
\begin{document}
\basesizes
Here is the \verb|\zleft| method which smashes the test box.
\[
y = \zleft( x^2 + 3\right)
\]
And now for the next test:
\[
y = \zleft(\frac{a}{b}\right)
\]
Finally:
\[
y = 3\zleft(\frac{\zleft( x^2 + 3\right)}{b}\right)
\]
\end{document}

在此处输入图片描述

相关内容