1

I want make a table. This is my code.

\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}

Now I want to modify the table as this picture: enter image description here

(1) I want for second column, for second until sixth row is left aligned.

(2) I want for all cell is vertically centered.

(3) I want to add extra space for every row.

Anyone can help me how to write this table?

2

Like this:

enter image description here

(red lines shows text borders)

With help of makecell packages:

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.