
我只是想在我的投影機幻燈片中的方程式周圍放置一個框架。
為此,我使用包 tcolorbox。
下面的 MWE 產生框,其中方程式幾乎在框的底部對齊。我希望它們垂直居中。
但是,使用“valign=center”沒有效果。
(我已經有了第二個方程中水平問題的解決方案,只是由於 MWE 原因沒有包含它)
\documentclass{beamer}
\usepackage{tcolorbox}
\newtcolorbox{equationframe}{
valign=center,
}
\begin{document}
\begin{frame}
\begin{itemize}
\item[]
\begin{equationframe}
\begin{equation*}
p(x,y)=\begin{cases}
\min\{q(x,y),\frac{\pi({y})q(y,{x})}{\pi(x)}\}, \quad x\neq y\\
1-\int_{x\neq y} p(x,y)
\end{cases}
\end{equation*}
\end{equationframe}
\begin{equationframe}
\begin{equation*}
\pi(x)p(x,y)=\min\{\pi(x)q(x,y),\pi(y)q(y,x)\}=\pi(y)p(y,x)%
\end{equation*}
\end{equationframe}
\end{itemize}
\end{frame}
\end{document}
編輯:
如果我使用序言
\documentclass{beamer}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems}
\newtcolorbox{equationframe}{
ams nodisplayskip
}
然後我得到
缺少 $ 插入。 \結束{幀}
這不是問題,因為我意識到使用ams align*
而不是ams nodisplayskip
按照我想要的方式進行垂直對齊,並且我最初的 MWE 編譯得很好。我只有一個問題沒有包含在 MWE 中:為了擬合水平超長方程,我使用了宏
\newcommand\fiteq[1]{%
\sbox{\mybox}{$\displaystyle#1$}%
\ifdim\wd\mybox>.85\textwidth\resizebox{.85\textwidth}{!}{\usebox{\mybox}}%
\else\usebox{\mybox}\fi%
}
\newsavebox{\mybox}
進而
\begin{equationframe}
\fiteq{A=......=B}
\end{equationframe}
不幸的是,對齊命令\\
和&
在此巨集中不起作用。
我只想要一個包含方程式的盒子。在普通乳膠中,水平到長的方程式並不是那麼有問題,但是當方程式周圍有一個框,並且方程式穿過邊界時,它看起來真的很愚蠢。
有兩個選項:(1)調整框的大小或(2)調整方程式的大小。
巨集 \fiteq{} 執行 (2),我真的很喜歡它的外觀。如果有人可以調整巨集以使用對齊命令,那就太好了(只要不使用換行符或與號,它就可以與上述解決方案一起使用)。如果這是不可能的,朝(1)方向發展的解決方案也將受到歡迎
答案1
載入theorems
庫(我使用類別選項來完成most
)並使用ams
或任何其他數學選項。
ams
用 設定上部和下部為數學模式\displaystyle
。你不需要equation
環境就是這些盒子。而你不需要valign
。
\documentclass{beamer}
\usepackage[most]{tcolorbox}
\newtcolorbox{equationframe}{
math
}
\begin{document}
\begin{frame}
\begin{itemize}
\item[]
\begin{equationframe}
p(x,y)=\begin{cases}
\min\{q(x,y),\frac{\pi({y})q(y,{x})}{\pi(x)}\}, \quad x\neq y\\
1-\int_{x\neq y} p(x,y)
\end{cases}
\end{equationframe}
\begin{equationframe}
\pi(x)p(x,y)=\min\{\pi(x)q(x,y),\pi(y)q(y,x)\}=\pi(y)p(y,x)%
\end{equationframe}
\end{itemize}
\end{frame}
\end{document}
更新:ams equation*
,ams align*
:
除了 之外math
,tcolorbox
還提供了一些其他數學框:ams equation
, ams align
, ams gather
, ...
\documentclass{beamer}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{frame}
\begin{tcolorbox}[ams equation*]
p(x,y)=\begin{cases}
\min\{q(x,y),\frac{\pi({y})q(y,{x})}{\pi(x)}\}, \quad x\neq y\\
1-\int_{x\neq y} p(x,y)
\end{cases}
\end{tcolorbox}
\begin{tcolorbox}[ams nodisplayskip, ams align*]
\pi(x)p(x,y) & =\min\{\pi(x)q(x,y),\pi(y)q(y,x)\}\\
& =\pi(y)p(y,x)%
\end{tcolorbox}
\end{frame}
\end{document}