\documentclass[11pt]{article}
\usepackage[margin=.2in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{empheq}
\begin{document}
\begin{empheq}[box=\fbox]{align*}
\sin(A+B)&=\sin A\cos B+\cos A\sin B\\
\sin(A-B)&=\sin A\cos B-\cos A\sin B\\
\cos(A+B)&=\cos A\cos B-\sin A\sin B\\
\cos(A-B)&=\cos A\cos B+\sin A\sin B
\end{empheq}
\begin{empheq}[box=\fbox]{align*}
\sin(A+B)+\sin(A-B)&=2\sin A\cos B\\
\sin(A+B)-\sin(A-B)&=2\cos A\sin B\\
\cos(A-B)+\cos(A+B)&=2\cos A\cos B\\
\cos(A-B)-\cos(A+B)&=2\sin A\sin B
\end{empheq}
\end{document}
此处的框是垂直放置的。我该如何让它们并排显示?
答案1
老实说,我发现empheq
这里有些过度了。
\documentclass{article}
\usepackage[margin=.2in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage{amsmath}% or empheq, which loads mathtools, which loads amsmath
\begin{document}
Lorem ipsum dolor sit et amet.
\[
\boxed{
\begin{aligned}
\sin(A+B)&=\sin A\cos B+\cos A\sin B\\
\sin(A-B)&=\sin A\cos B-\cos A\sin B\\
\cos(A+B)&=\cos A\cos B-\sin A\sin B\\
\cos(A-B)&=\cos A\cos B+\sin A\sin B
\end{aligned}}
\quad
\boxed{
\begin{aligned}
\sin(A+B)+\sin(A-B)&=2\sin A\cos B\\
\sin(A+B)-\sin(A-B)&=2\cos A\sin B\\
\cos(A-B)+\cos(A+B)&=2\cos A\cos B\\
\cos(A-B)-\cos(A+B)&=2\sin A\sin B
\end{aligned}}
\]
Lorem ipsum dolor sit et amet.
\end{document}
不过你需要一个非常小的边距才能适应这一点......
答案2
我建议使用这个彩色版本:
\documentclass[11pt]{article}
\usepackage[svgnames]{xcolor}
\usepackage[margin=.2in, paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage{empheq}
\makeatletter
\newcommand{\colorboxed}[3][white]{\fcolorbox{#2}{#1}{\m@th$\displaystyle#3$}}
\makeatother
\begin{document}
\[ \setlength{\fboxsep}{0.5em}\setlength{\fboxrule}{1pt}\colorboxed{IndianRed}{\begin{aligned}
\sin(A+B)&=\sin A\cos B+\cos A\sin B\\
\sin(A-B)&=\sin A\cos B-\cos A\sin B\\
\cos(A+B)&=\cos A\cos B-\sin A\sin B\\
\cos(A-B)&=\cos A\cos B+\sin A\sin B
\end{aligned}}
\qquad
\colorboxed[LavenderBlush!40]{IndianRed}{\begin{aligned}
\sin(A+B)+\sin(A-B)&=2\sin A\cos B\\
\sin(A+B)-\sin(A-B)&=2\cos A\sin B\\
\cos(A-B)+\cos(A+B)&=2\cos A\cos B\\
\cos(A-B)-\cos(A+B)&=2\sin A\sin B
\end{aligned}}
\]
\end{document}
无关amsmath
:加载时无需加载mathtools
:后者会为您加载。mathtools
和有类似注释empheq
。