我需要对欧拉方法的几次迭代进行排版,但我无法以易于阅读的方式描述它。以下是我现在所拥有的:
\documentclass[11pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ccccc}
\toprule
$n$ & $t_n$ & $y'(t_{n-1},y_{n-1})$ & $y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})$ \\\midrule
1 & 0 & -- & 1 \\
2 & 0.2 & $-2\cdot1+1-e^0 = -2$ & $1 + 0.2(-2) = 0.6$ \\
3 & 0.4 & $-2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65$ & $0.6 + 0.2(-0.65) = 0.47$\\
\bottomrule
\end{tabular}
\end{document}
答案1
在我看来,唯一让上面的内容难以阅读的是行和数组之间的间距。我认为稍微调整一下就可以解决这个问题(注意:我调整了表格的大小,以便\scalebox
它适合,因此才有了graphicx
包):
\documentclass[11pt]{article}
\usepackage{booktabs}
\usepackage{graphicx}
\begin{document}
\def\arraystretch{2}
\setlength\tabcolsep{23pt}
\begin{center}
\scalebox{0.7}{
\begin{tabular}{c c c c c}
\toprule
$n$ & $t_n$ & $y'(t_{n-1},y_{n-1})$ & $y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})$ \\\midrule
1 & 0 & -- & 1 \\
2 & 0.2 & $-2\cdot1+1-e^0 = -2$ & $1 + 0.2(-2) = 0.6$ \\
3 & 0.4 & $-2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65$ & $0.6 + 0.2(-0.65) = 0.47$\\
\bottomrule
\end{tabular}
}
\end{center}
\end{document}
希望我的帖子对您有帮助。谢谢。
答案2
以下内容适合标准文本宽度,但我还建议如何使表格稍微小一些。
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\begin{document}
\noindent X\dotfill X
\[
\begin{array}{@{} c c c c @{}}
\toprule
n & t_n & y'(t_{n-1},y_{n-1}) & y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})
\\
\midrule
1 & 0 & - & 1 \\
\addlinespace
2 & 0.2 & -2\cdot1+1-e^0 = -2 & 1 + 0.2(-2) = 0.6 \\
\addlinespace
3 & 0.4 & -2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65 & 0.6 + 0.2(-0.65) = 0.47 \\
\bottomrule
\end{array}
\]
X\dotfill X
\[
\mbox{\small$\begin{array}{@{} c c c c @{}}
\toprule
n & t_n & y'(t_{n-1},y_{n-1}) & y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})
\\
\midrule
1 & 0 & - & 1 \\
\addlinespace
2 & 0.2 & -2\cdot1+1-e^0 = -2 & 1 + 0.2(-2) = 0.6 \\
\addlinespace
3 & 0.4 & -2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65 & 0.6 + 0.2(-0.65) = 0.47 \\
\bottomrule
\end{array}$}
\]
\end{document}
如果您有几张这样的表,但有些不适合,那么最好定义一个合适的环境。
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\NewDocumentEnvironment{sizedarray}{O{}+b}
{\mbox{#1$\begin{array}#2\end{array}$}}
{}
\begin{document}
\noindent X\dotfill X
\[
\begin{sizedarray}{@{} c c c c @{}}
\toprule
n & t_n & y'(t_{n-1},y_{n-1}) & y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})
\\
\midrule
1 & 0 & - & 1 \\
\addlinespace
2 & 0.2 & -2\cdot1+1-e^0 = -2 & 1 + 0.2(-2) = 0.6 \\
\addlinespace
3 & 0.4 & -2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65 & 0.6 + 0.2(-0.65) = 0.47 \\
\bottomrule
\end{sizedarray}
\]
X\dotfill X
\[
\begin{sizedarray}[\small]{@{} c c c c @{}}
\toprule
n & t_n & y'(t_{n-1},y_{n-1}) & y_n = y_{n-1} + (t_n - t_{n-1})y'(t_{n-1},y_{n-1})
\\
\midrule
1 & 0 & - & 1 \\
\addlinespace
2 & 0.2 & -2\cdot1+1-e^0 = -2 & 1 + 0.2(-2) = 0.6 \\
\addlinespace
3 & 0.4 & -2\cdot0.6+ 1 - e^{-4\cdot0.2} \approx -0.65 & 0.6 + 0.2(-0.65) = 0.47 \\
\bottomrule
\end{sizedarray}
\]
\end{document}
输出是一样的。