我想制作一张表格。这是我的代码。
\documentclass{article}
\usepackage[left=2 cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amsmath,array}
\renewcommand{\arraystretch}{1.2}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{center}
\begin{tabular}{|c|c|P{2cm}|P{1.5cm}|P{1.5cm}|P{1.5cm}|P{1.5cm}|}
\hline
&Differential Equations&Independent Variables&Dependent Variables&Linear/ Nonlinear& Order& Degree\\
\hline
a.&$x^2\dfrac{d^2y}{dx^2}-6y\dfrac{dy}{dx}=0$&$x$&$y$&linear&$2$&$1$\\
\hline
b.&$\dfrac{d^2Q}{dt^2}-6\dfrac{dQ}{dt}+10Q=4$&$t$&$Q$&linear&$2$&$1$\\
\hline
c.&$2y\left(\dfrac{d^3y}{dx^3}\right)^2+5\dfrac{dy}{dx}+2xy=\cos x$&$x$&$y$&non linear&$3$&$2$\\
\hline
d.&$\dfrac{\partial u}{\partial x}+\dfrac{\partial u}{\partial t}+xt=0$&$x, t$&$u$&linear&$1$&$1$\\
\hline
e.&$1+\left(\dfrac{dy}{dx}\right)^2=3\dfrac{d^2y}{dx^2}$&$x$&$y$&non linear&$2$&$1$\\
\hline
\end{tabular}
\end{center}
\end{document}
(1)我希望第二列、第二行直到第六行左对齐。
(2)我希望所有单元格都垂直居中。
(3)我想为每一行添加额外的空间。
谁能帮我写这个表格?
答案1
像这样:
(红线表示文字边框)
借助makecell
软件包:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{amsmath}
\usepackage{makecell}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{center}
\setcellgapes{5pt}
\makegapedcells
\begin{tabular}{|c| l | *{5}{c|} }
\Xhline{1.2pt}
& \makecell{Differential Equations}
& \makecell{Independent\\ Variables}
& \makecell{Dependent\\ Variables}
& \makecell{Linear/\\ Nonlinear}
& Order
& Degree \\
\Xhline{0.8pt}
a. & $x^2\dfrac{d^2y}{dx^2}-6y\dfrac{dy}{dx}=0$
& $x$ & $y$ & linear & $2$ & $1$ \\
\hline
b. & $\dfrac{d^2Q}{dt^2}-6\dfrac{dQ}{dt}+10Q=4$
& $t$ & $Q$ & linear & $2$ & $1$ \\
\hline
c. & $2y\left(\dfrac{d^3y}{dx^3}\right)^2+5\dfrac{dy}{dx}+2xy=\cos x$
& $x$ & $y$ & non linear & $3$ & $2$ \\
\hline
d. & $\dfrac{\partial u}{\partial x}+\dfrac{\partial u}{\partial t}+xt=0$
& $x, t$ & $u$ & linear & $1$ & $1$ \\
\hline
e. & $1+\left(\dfrac{dy}{dx}\right)^2=3\dfrac{d^2y}{dx^2}$
& $x$ & $y$ & non linear & $2$ & $1$ \\
\Xhline{1.2pt}
\end{tabular}
\end{center}
\end{document}