当我仅尝试使用第一行和第二行时它可以工作但是添加另一行后它不工作,为什么?
$$
\begin{array}{|l|l|l|l|}
x & f(x) & g(x) & h(x) \\ \hline
0.5 & 0.094080 & 0.122417 & {\rm does\,not\,exist}\\
-0.5 &0.094080 &0.122417&−0.618033\\
0.02 &1.995203 & 0.124995 & −1.043560\\
-0.02 &1.995203 &0.124995&−0.962912\\
0.001 &1.999988 &0.124999&-1.002008\\
-0.001 &1.999988 &0.124999&-0.998007\\
0.0005 &1.999997 & 0.125 &-1.001002\\
-0.0005 &1.999997 & 0.125 &-0.999001\\
0.00004 &1.999999 & 0.125 &-1.000080\\
-0.00004 &1.999999 & 0.125 &-0.999920\\
0.000005 &2 &0.12501 &−1.00001\\
-0.000005 &2 &0.12501 & -0.99999\\
\end{array}
$$
答案1
使用包S
中定义的列类型siunitx
。您可能喜欢:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\[
\begin{array}{|S[table-format=-1.6]|
*{2}{S[table-format= 1.6]|}
S[table-format=-1.6]|}
{x} & {f(x)} & {g(x)} & {h(x)} \\
\hline
0.5 & 0.094080 & 0.122417 & {\text{not exist}} \\
-0.5 & 0.094080 & 0.122417 & -0.618033 \\
0.02 & 1.995203 & 0.124995 & -1.043560 \\
-0.02 & 1.995203 & 0.124995 & -0.962912 \\
0.001 & 1.999988 & 0.124999 & -1.002008 \\
-0.001 & 1.999988 & 0.124999 & -0.998007 \\
0.0005 & 1.999997 & 0.125 & -1.001002 \\
-0.0005 & 1.999997 & 0.125 & -0.999001 \\
0.00004 & 1.999999 & 0.125 & -1.000080 \\
-0.00004 & 1.999999 & 0.125 & -0.999920 \\
0.000005 & 2 & 0.12501 & -1.00001 \\
-0.000005 & 2 & 0.12501 & -0.99999 \\
\end{array}
\]
\end{document}
答案2
-
由于某种原因,您的代码中出现了非标准字符。此示例有效:
\documentclass{article}
\begin{document}
\[
\begin{array}{|l|l|l|l|}
x & f(x) & g(x) & h(x) \\
\hline
0.5 & 0.094080 & 0.122417 & \textrm{does not exist} \\
-0.5 & 0.094080 & 0.122417 & -0.618033 \\
0.02 & 1.995203 & 0.124995 & -1.043560 \\
-0.02 & 1.995203 & 0.124995 & -0.962912 \\
0.001 & 1.999988 & 0.124999 & -1.002008 \\
-0.001 & 1.999988 & 0.124999 & -0.998007 \\
0.0005 & 1.999997 & 0.125 & -1.001002 \\
-0.0005 & 1.999997 & 0.125 & -0.999001 \\
0.00004 & 1.999999 & 0.125 & -1.000080 \\
-0.00004 & 1.999999 & 0.125 & -0.999920 \\
0.000005 & 2 & 0.12501 & -1.00001 \\
-0.000005 & 2 & 0.12501 & -0.99999 \\
\end{array}
\]
\end{document}