我有以下内容输出当我尝试为班级创建求和公式的枚举时。我试图复制这但由于总和相当高,我遇到了总和大小与行高匹配的问题。
无论我如何尝试将它们向左冲,它们似乎都集中到了中心。
这是我目前的代码:
\begin{enumerate}
\item \[ \sum_{i=1}^{n} 1 = n \]
\item \[ \sum_{i=1}^{n} i = 1 + 2 + ... + n = \frac{n(n+1)}{2}\approx \frac{1}{2}n^2\]
\item \[ \sum_{i=1}^{n} i^2 = 1^2 + 2^2 + ... + n^2 = \frac{n(n+1)(2n+1)}{6}\approx \frac{1}{3}n^3\]
\item \[ \sum_{i=1}^{n} i^k = 1^k + 2^k + ... + n^k = \frac{1}{k+1}n^k+1\]
\item \[ \sum_{i=0}^{n} a^i = 1+a + ... + a^n = \frac{a^{n+1}-1}{a-1}(a\neq 1); \sum_{i=0}^{n} 2^i = 2^{n+1} - 1\]
\item \[ \sum_{i=1}^{n} i2^i = 1\cdot 2 + 2 \cdot 2^2 + ... + n2^n = (n-1)2^{n+1}+2\]
\item \[ \sum_{i=1}^{n}\frac{1}{i} = 1+\frac{1}{2} + ...+...\frac{1}{n}\approx \text{ln n + }\gamma\text{, where} \gamma \approx \text{0.5772...(Euler's Constant)}\]
\item \[ \sum_{i=1}^{n} \text{lg i} \approx \text{n lg n}\]
\end{enumerate}
答案1
您可以使用的功能enumitem
添加\displaystyle
到所有数学公式中,否则您应该在每个公式中手动添加$...$
\documentclass{article}
\usepackage{geometry} % more generous margins
\usepackage{amsmath}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=\textbf{\arabic*.},before=\everymath{\displaystyle}]
\item $\sum_{i=1}^{n} 1 = n$
\item $\sum_{i=1}^{n} i = 1 + 2 + \dots + n = \frac{n(n+1)}{2} \approx \frac{1}{2}n^2$
\item $\sum_{i=1}^{n} i^2 = 1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}\approx \frac{1}{3}n^3$
\item $\sum_{i=1}^{n} i^k = 1^k + 2^k + \dots + n^k = \frac{1}{k+1}n^{k+1}$
\item $\sum_{i=0}^{n} a^i = 1+a + \dots + a^n = \frac{a^{n+1}-1}{a-1}(a\neq 1)$; \quad $\sum_{i=0}^{n} 2^i = 2^{n+1} - 1$
\item $\sum_{i=1}^{n} i2^i = 1\cdot 2 + 2 \cdot 2^2 + \dots + n \cdot 2^n = (n-1)2^{n+1}+2$
\item $\sum_{i=1}^{n}\frac{1}{i} = 1+\frac{1}{2} + \dots + \frac{1}{n}\approx \ln n + \gamma$, where $\gamma \approx 0.5772\dots$ (Euler's Constant)
\item $\sum_{i=1}^{n} \lg i \approx n \lg n$
\end{enumerate}
\end{document}
其他评论:
amsmath
在这里并不是真正必要的,但当你的数学公式包含超过的内容时,无论如何都应该加载1+1=2
。- 不要写三个点的省略号
...
,而是使用宏\dots
。amsmath
这样会自动选择最佳版本。 \text
用于文本;对数等数学运算符应输入为\ln
,\lg
。
答案2
考虑尝试以下方法:
\documentclass{article}
\usepackage{enumitem}
\newlist{mathlist}{enumerate}{1}
\setlist[mathlist,1]{label={\arabic*.}}
\begin{document}
\begin{enumerate}
\item $\sum_{i=1}^{n} 1 = n$
\item $\sum_{i=1}^{n} i = 1 + 2 + ... + n = \frac{n(n+1)}{2}\approx \frac{1}{2}n^2$
\item $\sum_{i=1}^{n} i^2 = 1^2 + 2^2 + ... + n^2 = \frac{n(n+1)(2n+1)}{6}\approx \frac{1}{3}n^3$
\item $\sum_{i=1}^{n} i^k = 1^k + 2^k + ... + n^k = \frac{1}{k+1}n^k+1$
\item $\sum_{i=0}^{n} a^i = 1+a + ... + a^n = \frac{a^{n+1}-1}{a-1}(a\neq 1); \sum_{i=0}^{n} 2^i = 2^{n+1} - 1$
\item $\sum_{i=1}^{n} i2^i = 1\cdot 2 + 2 \cdot 2^2 + ... + n2^n = (n-1)2^{n+1}+2$
\item $\sum_{i=1}^{n}\frac{1}{i} = 1+\frac{1}{2} + ...+...\frac{1}{n}\approx \text{ln n + }\gamma\text{, where} \gamma \approx \text{0.5772...(Euler's Constant)}$
\item $\sum_{i=1}^{n} \text{lg i} \approx \text{n lg n}$
\end{enumerate}
\end{document}