忽略边距,使表格居中

忽略边距,使表格居中

如何使该表格居中而不忽略左边距,以使其直接位于中心? 在此处输入图片描述

下面是我的代码

    \begin{center}
    \centering
    \resizebox{!}{5cm} {
    \begin{tabular}{| l | r | }
    \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(x^n)=nx^{n-1}\) &  \(\int {x^n}\,\mathrm{d}x=\frac{1}{n+1}x^{n+1}+c, n\neq-1\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\mathrm{e}^{ax})=a\mathrm{e}^{ax}\) &  \(\int {\mathrm{e}^{ax}}\,\mathrm{d}x=\frac{1}{a}\mathrm{e}^{ax}+c\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\log_{\mathrm{e}} {(x)})=\frac{1}{x}\) &  \(\int {\frac{1}{x}}\,\mathrm{d}x=\log_{\mathrm{e}} {|x|}+c\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\sin{(ax)})=a\cos{(ax)}\) &  \(\int {\sin{(ax)}}\,\mathrm{d}x=-\frac{1}{a}\cos{(ax)}+c\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\cos{(ax)})=-a\sin{(ax)}\) &  \(\int {\cos{(ax)}}\,\mathrm{d}x=\frac{1}{a}\sin{(ax)}+c\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\tan{(ax)})=a\sec^2{(ax)}\) &  \(\int {\sec^2{(ax)}}\,\mathrm{d}x=\frac{1}{a}\tan{(ax)}+c\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\arcsin{(x)})=\frac{1}{\sqrt{1-x^2}}\) &  \(\int {\frac{1}{\sqrt{a^2-x^2}}\,\mathrm{d}x=\arcsin{(\frac{x}{a})}}+c, a>0\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\arccos{(x)})=\frac{-1}{\sqrt{1-x^2}}\) &  \(\int {\frac{-1}{\sqrt{a^2-x^2}}\,\mathrm{d}x=\arccos{(\frac{x}{a})}}+c, a>0\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\arctan{(x)})=\frac{1}{1+x^2}\) &  \(\int {\frac{a}{\sqrt{a^2+x^2}}\,\mathrm{d}x=\arctan{(\frac{x}{a})}}+c\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\frac{1}{a(n+1)}{(ax+b)}^{n+1})={(ax+b)}^n\) &  \(\int {{(ax+b)}^n}\,\mathrm{d}x=\frac{1}{a(n+1)}{(ax+b)}^{n+1}+c, n\neq-1\) \\ \hline
    \(\frac{\mathrm{d}}{\mathrm{d}x}(\frac{1}{a}log_{\mathrm{e}} |ax+b|)={(ax+b)}^{-1}\) &  \(\int {{(ax+b)}^{-1}}\,\mathrm{d}x=\frac{1}{a}log_{\mathrm{e}} |ax+b|+c\) \\
    \hline
    product rule &  \(\frac{\mathrm{d}}{\mathrm{d}x}(uv)=u\frac{\mathrm{d}v}{\mathrm{d}x}+v\frac{\mathrm{d}u}{\mathrm{d}x}\) \\ \hline
    quotient rule &  \(\frac{\mathrm{d}}{\mathrm{d}x}(\frac{u}{v})=\frac{v\frac{\mathrm{d}u}{\mathrm{d}x}-u\frac{\mathrm{d}v}{\mathrm{d}x}}{v^2}\) \\ \hline
    chain rule &  \(\frac{\mathrm{d}y}{\mathrm{d}x}=\frac{\mathrm{d}y}{\mathrm{d}u}\frac{\mathrm{d}u}{\mathrm{d}x}\) \\ \hline
    arc length & \(\int_{x_1}^{x_2} {\sqrt{1+{(f'(x))}^2}}\,\mathrm{d}x\) or \(\int_{t_1}^{t_2} {\sqrt{{(x'(t))}^{2}+{(y'(t))}^{2}}\,\mathrm{d}t}\) \\ \hline
  \end{tabular}
}
\end{center}

答案1

如果您不关心边距,请将表格的宽度减小到零,它就会居中。

\begin{center}
  \makebox[0cm]{... Table ...}
\end{center}

一些说明:

  • \begin{center}\centering ...\end{center}太多了,要么使用 要么 \begin{center} ... \end{center}使用{\centering ...}

  • 而不是\begin{tabular} ... each cell in \(...\) \end{tabular}更好地利用\(\begin{array} ... everything is automatically in math mode ... \end{array}\)

  • 如果您注重排版,请避免使用垂直线,并将水平线数量减少到定位所需的最低限度。

  • 对于数学模式中的文本,请使用或\text{...}包。amsmathmathtools

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath}
\usepackage{blindtext}
\usepackage{booktabs}
\newcommand\dd{\mathrm{d}}
\newcommand\ddx{\frac\dd{\dd x}}
\begin{document}
\blindtext
\begin{center}
  \makebox[0cm]%
    {\renewcommand\arraystretch{1.5}%
     \(\begin{array}{ll}
       \toprule
         \ddx(x^n)=nx^{n-1}
         &  \int {x^n}\,\dd x=\frac{1}{n+1}x^{n+1}+c, n\neq-1
       \\
         \ddx(\mathrm{e}^{ax})=a\mathrm{e}^{ax}
         &  \int {\mathrm{e}^{ax}}\,\dd x=\frac{1}{a}\mathrm{e}^{ax}+c
       \\
         \ddx(\log_{\mathrm{e}} {(x)})=\frac{1}{x}
         &  \int {\frac{1}{x}}\,\dd x=\log_{\mathrm{e}} {|x|}+c
       \\\midrule
         \ddx(\sin{(ax)})=a\cos{(ax)}
         &  \int {\sin{(ax)}}\,\dd x=-\frac{1}{a}\cos{(ax)}+c
       \\
         \ddx(\cos{(ax)})=-a\sin{(ax)}
         &  \int {\cos{(ax)}}\,\dd x=\frac{1}{a}\sin{(ax)}+c
       \\
         \ddx(\tan{(ax)})=a\sec^2{(ax)}
         &  \int {\sec^2{(ax)}}\,\dd x=\frac{1}{a}\tan{(ax)}+c
       \\\midrule
         \ddx(\arcsin{(x)})=\frac{1}{\sqrt{1-x^2}}
         &  \int {\frac{1}{\sqrt{a^2-x^2}}\,\dd x=\arcsin{(\frac{x}{a})}}+c, a>0
       \\
         \ddx(\arccos{(x)})=\frac{-1}{\sqrt{1-x^2}}
         &  \int {\frac{-1}{\sqrt{a^2-x^2}}\,\dd x=\arccos{(\frac{x}{a})}}+c, a>0
       \\
         \ddx(\arctan{(x)})=\frac{1}{1+x^2}
         &  \int {\frac{a}{\sqrt{a^2+x^2}}\,\dd x=\arctan{(\frac{x}{a})}}+c
       \\\midrule
         \ddx(\frac{1}{a(n+1)}{(ax+b)}^{n+1})={(ax+b)}^n
         &  \int {{(ax+b)}^n}\,\dd x=\frac{1}{a(n+1)}{(ax+b)}^{n+1}+c, n\neq-1
       \\
         \ddx(\frac{1}{a}\log_{\mathrm{e}} |ax+b|)={(ax+b)}^{-1}
         &  \int {{(ax+b)}^{-1}}\,\dd x=\frac{1}{a}\log_{\mathrm{e}} |ax+b|+c
       \\
         \text{product rule}
         &  \ddx(uv)=u\frac{\dd v}{\dd x}+v\frac{\dd u}{\dd x}
       \\\midrule
         \text{quotient rule}
         &  \ddx(\frac{u}{v})=\frac{v\frac{\dd u}{\dd x}-u\frac{\dd v}{\dd x}}{v^2}
       \\
         \text{chain rule}
         &  \frac{\dd y}{\dd x}=\frac{\dd y}{\dd u}\frac{\dd u}{\dd x}
       \\
         \text{arc length}
         & \int_{x_1}^{x_2} {\sqrt{1+{(f'(x))}^2}}\,\dd x\text{ or }\int_{t_1}^{t_2} {\sqrt{{(x'(t))}^{2}+{(y'(t))}^{2}}\,\dd t}
       \\\bottomrule
       \end{array}
     \)%
    }
\end{center}
\blindtext
\end{document}

答案2

由于几乎整个材料都由方程组成,因此请使用array环境而不是tabular环境。摆脱所有无意义和不必要的花括号。摆脱所有垂直线和大多数水平线。增加值\arraystretch。(我建议在我的答案中使用值1.5;随意尝试使用此参数的较小和较大值。)

在此处输入图片描述

\documentclass{article}
\usepackage{amsmath,booktabs}
\newcommand\ddx{\frac{\mathrm{d}}{\mathrm{d}x}}
\newcommand{\dee}{\mathop{\mathrm{d}\!}}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters appropriately

\begin{document}
\begin{center}
\renewcommand\arraystretch{1.5}
$\begin{array}{@{} ll  @{} }
\toprule
\ddx(x^n)=nx^{n-1} 
& \int x^n\dee x
  =\frac{1}{n+1}x^{n+1}+c,\ n\neq-1 \\ 
\ddx(\mathrm{e}^{ax})=a\mathrm{e}^{ax} 
& \int {\mathrm{e}^{ax}}\dee x
  =\frac{1}{a} \mathrm{e}^{ax}+c \\ 
\ddx(\log_{\mathrm{e}} (x))
  =\frac{1}{x} 
& \int\!\frac{1}{x}\dee x=\log_{\mathrm{e}} |x|+c \\ 
\ddx(\sin(ax))=a\cos(ax) 
& \int \sin(ax)\dee x
  =-\frac{1}{a}\cos(ax)+c \\ 
\ddx(\cos(ax))=-a\sin(ax) 
& \int\cos(ax)\dee x
  =\frac{1}{a}\sin(ax)+c \\
\ddx(\tan(ax))=a\sec^2(ax) 
& \int \sec^2(ax)\dee x
  =\frac{1}{a}\tan(ax)+c \\ 
\ddx(\arcsin(x))=\frac{1}{\sqrt{1-x^{2\mathstrut}}} 
& \int\!\frac{1}{\sqrt{a^2-x^{2\mathstrut}}}\dee x
  =\arcsin\bigl(\frac{x}{a}\bigr)+c,\ a>0 \\ 
\ddx(\arccos(x))=\frac{-1}{\sqrt{1-x^{2\mathstrut}}} 
& \int\!\frac{-1}{\sqrt{a^2-x^{2\mathstrut}}}\dee x
  =\arccos\bigl(\frac{x}{a}\bigr)+c,\ a>0 \\ 
\ddx(\arctan(x))=\frac{1}{1+x^{2\mathstrut}} 
& \int\!\frac{a}{\sqrt{a^2+x^{2\mathstrut}}}\dee x
  =\arctan\bigl(\frac{x}{a}\bigr)+c \\ 
\ddx\bigl(\frac{1}{a(n+1)}{(ax+b)}^{n+1}\bigr)
=(ax+b)^n 
& \int (ax+b)^n\dee x=\frac{1}{a(n+1)}(ax+b)^{n+1}+c,\ n\neq-1 \\ 
\ddx\bigl(\frac{1}{a}\log_{\mathrm{e}} |ax+b|\bigr)
=(ax+b)^{-1} 
& \int (ax+b)^{-1}\dee x
  =\frac{1}{a}\log_{\mathrm{e}} |ax+b|+c \\
\text{Product rule} 
& \ddx(uv)=u\frac{\mathrm{d}v}{\mathrm{d}x}
  +v\frac{\mathrm{d}u}{\mathrm{d}x} \\ 
\text{Quotient rule} &  \ddx\bigl(\frac{u}{v}\bigr)
  =\frac{v\frac{\mathrm{d}u}{\mathrm{d}x}
  -u \frac{\mathrm{d}v}{\mathrm{d}x}}{v^{2\mathstrut}} \\ 
\text{Chain rule} 
& \frac{\mathrm{d}y}{\mathrm{d}x}
  =\frac{\mathrm{d}y}{\mathrm{d}u}
   \frac{\mathrm{d}u}{\mathrm{d}x} \\ 
\text{Arc length} 
& \int_{x_1}^{x_2} \sqrt{1+(f'(x))^{2\mathstrut}}\dee x \text{ or } 
  \int_{t_1}^{t_2} \sqrt{(x'(t))^{2}+(y'(t))^{2\mathstrut}}\dee t \\ 
\bottomrule
\end{array}$
\end{center}
\end{document}

答案3

按照您在 MWE 中的形式(带有水平和垂直规则),我得到了下表:

在此处输入图片描述

\documentclass{article}
\usepackage[margin=30mm]{geometry}
\usepackage{array,makecell, tabularx}

\usepackage{showframe}% for show page layout
\renewcommand*\ShowFrameColor{\color{red}}% with red lines ... in real document remove this two lines

\usepackage{amsmath}
\newcommand\ud{\,\mathrm{d}} % shortcuts for d, du, dv, dx, dy 
\newcommand\udu{\ud\,u}
\newcommand\udv{\ud\,v}
\newcommand\udx{\ud\,x}
\newcommand\udy{\ud\,y}

\setcellgapes{5pt}

\begin{document}
 \centering
\makegapedcells
    \begin{tabularx}{\linewidth}{|>{$\displaystyle}l<{$} | >{$\displaystyle}X<{$}  | }
    \hline
\frac{\ud}{\udx}(x^n)=nx^{n-1}
    &   \int x^n \udx = \frac{1}{n+1}x^{n+1}+c,\; n\neq -1           \\ 
    \hline
\frac{\ud}{\udx}(\mathrm{e}^{ax})=a\mathrm{e}^{ax}
    &  \int \mathrm{e}^{ax} \udx = \frac{1}{a}\mathrm{e}^{ax}+c     \\
    \hline
\frac{\ud}{\udx}\left(\log_{\mathrm{e}} (x)\right) = \frac{1}{x}
    &   \int \frac{1}{x} \udx = \log_{\mathrm{e}} |x|+c             \\
    \hline
\frac{\ud}{\udx}(\sin(ax))=a\cos(ax)
    &  \int \sin(ax) \udx = -\frac{1}{a}\cos(ax)+c                  \\
    \hline
\frac{\ud}{\udx}(\cos(ax)) = -a\sin(ax)
    &  \int \cos(ax)\udx = \frac{1}{a}\sin(ax)+c                   \\
    \hline
\frac{\ud}{\udx}(\tan(ax)) = a\sec^2 (ax)
    &  \int \sec^2(ax) \udx = \frac{1}{a}\tan{(ax)}+c               \\
    \hline
\frac{\ud}{\udx}(\arcsin(x)) = \frac{1}{\sqrt{1-x^2}}
    & \int \frac{1}{\sqrt{a^2-x^2} \udx = \arcsin(\frac{x}{a})}+c,\; a>0    \\
    \hline
\frac{\ud}{\udx}(\arccos(x)) = \frac{-1}{\sqrt{1-x^2}}
    & \int \frac{-1}{\sqrt{a^2-x^2}} \udx=\arccos(\frac{x}{a})+c,\; a>0    \\
    \hline
\frac{\ud}{\udx}(\arctan(x)) = \frac{1}{1+x^2}
    & \int \frac{a}{\sqrt{a^2+x^2}} \udx = \arctan(\frac{x}{a})+c           \\
    \hline
\frac{\ud}{\udx}\left(\frac{1}{a(n+1)}(ax+b)^{n+1}\right) = (ax+b)^n
    & \int (ax+b)^n \udx = \frac{1}{a(n+1)} (ax+b)^{n+1}+c,\; n\neq-1       \\
    \hline
\frac{\ud}{\udx}\left(\frac{1}{a}\log_{\mathrm{e}} |ax+b|\right) = (ax+b)^{-1}
    & \int (ax+b)^{-1} \udx = \frac{1}{a}\log_{\mathrm{e}} |ax+b|+c         \\
    \hline
\text{product rule}
    &  \frac{\ud}{\udx}(uv) = u\frac{\udv}{\udx}+v\frac{\udu}{\udx}         \\
    \hline
\text{quotient rule}
    & \frac{\ud}{\udx}(\frac{u}{v}) = \frac{v\frac{\udu}{\udx}-u\frac{\udv}{\udx}}{v^2}  \\ \hline
\text{chain rule}
    &  \frac{\udy}{\udx}=\frac{\udy}{\udu}\frac{\udu}{\udx}                 \\ 
    \hline
\text{arc length}
    &   \int_{x_1}^{x_2} \sqrt{1+(f'(x))^2} \udx  \text{ or }
        \int_{t_1}^{t_2} \sqrt{(x'(t))^2 + (y'(t))^2 \ud\,t}              \\ 
    \hline
    \end{tabularx}
\end{document}

为了在单元格中留出更多空间,可以使用\maqkegapedcells包中的makecell。还定义了四个新命令,例如\,\matrm{d}等,以便更简短地书写方程式。红色框显示页面布局,在实际使用中必须将其删除。

相关内容