我目前想排版一个具有长积分边框的积分。但是,要么我在积分符号后和积分函数前留有太多空间,要么边框对齐错误:
如何排版长整数边框?
平均能量损失
\documentclass[a5paper]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{mathtools}
\begin{document}
\section*{With mathclap}
\begin{align*}
\int_S f \mathrm{d} A &= \sum_{i=1}^n \int_{\mathclap{V_i}} f \mathrm{d} A \\
&- \sum_{i \neq j} \int_{\mathclap{V_i \cap V_j}} f \mathrm{d} A \\
&+ \sum_{i,j,k} \int_{\mathclap{V_i \cap V_j \cap V_k}} f \mathrm{d} A\\
&- \dots
\end{align*}
\section*{Without mathclap}
\begin{align*}
\int_S f \mathrm{d} A &= \sum_{i=1}^n \int_{V_i} f \mathrm{d} A \\
&- \sum_{i \neq j} \int_{V_i \cap V_j} f \mathrm{d} A \\
&+ \sum_{i,j,k} \int_{V_i \cap V_j \cap V_k} f \mathrm{d} A\\
&- \dots
\end{align*}
\end{document}
答案1
\mathrlap{…}
可以完成这项工作。
\documentclass[a5paper]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{mathtools}
\begin{document}
\section*{With mathrlap}
\begin{align*}
\int_S f \mathrm{d} A &= \sum_{i=1}^n \int_{\mathrlap{V_i}} f \mathrm{d} A \\
&- \sum_{i \neq j} \int_{\mathrlap{V_i \cap V_j}} f \mathrm{d} A \\
&+ \sum_{i,j,k} \int_{\mathrlap{V_i \cap V_j \cap V_k}} f \mathrm{d} A\\
&- \dots
\end{align*}
\section*{Without mathrlap}
\begin{align*}
\int_S f \mathrm{d} A &= \sum_{i=1}^n \int_{V_i} f \mathrm{d} A \\
&- \sum_{i \neq j} \int_{V_i \cap V_j} f \mathrm{d} A \\
&+ \sum_{i,j,k} \int_{V_i \cap V_j \cap V_k} f \mathrm{d} A\\
&- \dots
\end{align*}
\end{document}
答案2
对于这样的公式,需要进行一些手动调整。
\documentclass[a5paper]{scrartcl}
\usepackage{amsmath} % needed for math
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\newcommand{\back}[1]{\mspace{-#1mu}}
\begin{document}
\begin{align*}
\int_S f \diff A
& = \sum_{i=1}^n \; \int\limits_{V_i} f \diff A \\
&\quad - \sum_{i \neq j} \; \int\limits_{V_i \cap V_j} \back{6} f \diff A \\
&\quad + \sum_{i,j,k} \; \int\limits_{V_i \cap V_j \cap V_k} \back{12} f \diff A\\
&\quad - \dotsb
\end{align*}
\end{document}
你\back
会得到一些后退空间。积分域应该在积分符号下方。
不要使用显式\mathrm{d}
来表示差异(也不要使用直立的“d”,但这是另一回事),最好使用高级命令。我建议的命令会自动处理“d”之前的细空格。
答案3
\documentclass[a5paper]{scrartcl}
\usepackage{amssymb, amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{mathtools}
\usepackage{stackengine}
\stackMath
\begin{document}
\section*{With stacks}
\begin{align*}
\int_S f \mathrm{d} A &= \sum_{i=1}^n \stackunder{%
\displaystyle\int}{\scriptstyle V_i} f \mathrm{d} A \\
&- \sum_{i \neq j} \def\stackalignment{l}\addstackgap{\stackunder{%
\displaystyle\int}{\rlap{$\scriptstyle V_i \cap V_j$}}} f \mathrm{d} A \\
&- \sum_{i ,j,k} \def\stackalignment{l}\addstackgap{\stackunder{%
\displaystyle\int}{\rlap{$\scriptstyle V_i \cap V_j\cap V_k$}}} f \mathrm{d} A \\
&- \dots
\end{align*}
\end{document}
已编辑以提供方程式之间的更多垂直间隙。