我正在尝试将“定积分的性质”子部分下的公式居中并框起来;但是,框并没有包裹住公式,而是向右延伸了一点,我无法将其居中。我尝试使用,\begin{center}
但\end{center}
可惜没有用。有人能给点建议吗?我附上了一张照片供参考。
\documentclass{article}
\usepackage{gensymb}
\usepackage{graphicx}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fullpage}
\usepackage{cancel}
\usepackage{easylist}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{framed}
\usepackage{tcolorbox}
\begin{document}
\section{Integrals}
\subsection{Integral Properties \& Formulas}
\subsubsection{Properties of Definite Integrals}
\begin{framed}
\begin{itemize}
\item[I.] $\displaystyle{\int_a^b k\,dx=k(b-a)}$
\item[II.] $\displaystyle{\int_a^b k\cdot f(x)dx=k\cdot \int_a^b f(x)dx}$
\end{itemize}
\end{framed}
\end{document}
答案1
以下是两个可能的选择:
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{framed,varwidth}
\begin{document}
\section{Integrals}
\begin{framed}
\begin{itemize}
\item[I.] $\displaystyle \int_a^b k \mathrm{d}x = k(b - a)$
\item[II.] $\displaystyle \int_a^b k \cdot f(x) \mathrm{d}x = k \cdot \int_a^b f(x) \mathrm{d}x$
\end{itemize}
\end{framed}
\begin{center}
\fbox{\quad%
\begin{varwidth}{\linewidth}
\begin{itemize}
\item[I.] $\displaystyle \int_a^b k \mathrm{d}x = k(b - a)$
\item[II.] $\displaystyle \int_a^b k \cdot f(x) \mathrm{d}x = k \cdot \int_a^b f(x) \mathrm{d}x$
\end{itemize}
\end{varwidth}%
\quad}
\end{center}
\begin{center}
$\begin{array}{|@{\quad}rl@{\quad}|}
\hline
& \\
\text{I.} & \displaystyle \int_a^b k \mathrm{d}x = k(b - a) \\
\text{II.} & \displaystyle \int_a^b k \cdot f(x) \mathrm{d}x = k \cdot \int_a^b f(x) \mathrm{d}x \\
& \\
\hline
\end{array}$
\end{center}
\end{document}
第一个使用\fbox
edvarwidth
环境,而第二个框是常规的array
。
答案2
您可以使用empheq
:
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{empheq}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\newenvironment{boxedalign}
{\setlength\mathindent{0pt}%
\empheq[box=\fbox]{align*}}
{\endempheq}
\begin{document}
\section{Integrals}
Some text just to show alignment with the left margin
that should fill a line and go to the next one
\begin{boxedalign}
\textup{I.}\quad & \int_a^b k \diff x = k(b - a) \\
\textup{II.}\quad & \int_a^b k \cdot f(x) \diff x = k \cdot \int_a^b f(x) \diff x
\end{boxedalign}
\end{document}