微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

缩放等式*以适合精确的页面宽度

如何解决缩放等式*以适合精确的页面宽度

我有一个投影仪演示文稿,其中包含许多对于一条线来说太大的方程。
我想自动缩放它们以适应。
Scale an equation to fit exact page widthhttps://stackoverflow.com/users/3383640/suuuehgi解决方案很棒。

但是我不想要公式编号 - 我希望将相同的大小调整应用于所有公式*位。
我不知道如何调整代码来处理这个问题。非常感谢帮助!

解决方法

以下代码使用了稍微改进的方法,注意显示方程中的内容是使用 \displaystyle 设置的(不包含在 linked answer 中的度量内)。原则上,方法是一样的:

  • 内容是横向测量的。
  • 如果内容比 \linewidth 宽,则会调整其大小以适应。

重新定义了 equation* 速记以适应这种新方法。

enter image description here

\documentclass{beamer}

\usepackage{environ}

\newlength{\myl}
\expandafter\let\expandafter\origequation\csname equation*\endcsname
\expandafter\let\expandafter\endorigequation\csname endequation*\endcsname
\long\def\[#1\]{\begin{equation*}#1\end{equation*}}
\RenewEnviron{equation*}{
  \settowidth{\myl}{$\displaystyle\BODY$} % calculate width and save as \myl
  \origequation
    \ifdim\myl>\linewidth
      \resizebox{\linewidth}{!}{$\displaystyle\BODY$}% \myl > \linewidth
    \else
      \BODY % \myl <= \linewidth
    \fi
  \endorigequation
}

\begin{document}

\begin{frame}
  \begin{equation*}
    f(x) = ax^2 + bx + c
  \end{equation*}
  
  \begin{equation*}
    g(x) = ax^2 + bx + c 
      - ax^2 - bx - c 
      + ax^2 + bx + c
      - ax^2 - bx - c
      + ax^2 + bx + c
  \end{equation*}
  
  \[
    h(x) = \int_a^b \frac{c}{d} x\,\mathrm{d}x
  \]
  
  \[
    i(x) = \int_a^b \frac{c}{d} x\,\mathrm{d}x
      - \int_a^b \frac{c}{d} x\,\mathrm{d}x
      + \int_a^b \frac{c}{d} x\,\mathrm{d}x
  \]
\end{frame}

\end{document}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。