3

My question is, how can I change the height of rows in my table?

MWE:

\documentclass[12pt, a4paper]{article}
\usepackage[top=0.7 in,bottom=0.7 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\usepackage{parskip}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
%reduce top margin
\addtolength{\headsep}{-0.5cm}
%for line spacing
\usepackage{setspace}

\renewcommand{\baselinestretch}{0.7} 
\begin{document}
\large
\begin{center}
    \begin{tabular}{|Sc|Sc|}
        \hline
        \textbf{Natural number} & \textbf{Cube} \\ \hline
        1 & $1^3 = 1\times 1\times 1 = 1$  \\ \hline
        2 & $2^3 = 2\times 2\times 2 = 8$  \\ \hline
        3 & $3^3 = 3\times 3\times 3 = 27$  \\ \hline
        4 & $4^3 = 4\times 4\times 4 = 64$   \\ \hline
        5 & $5^3 = 5\times 5\times 5 = 125$  \\ \hline
        6 & $6^3 = 6\times 6\times 6 = 216$  \\ \hline
        7 & $7^3 = 7\times 7\times 7 = 343$  \\ \hline
        8 & $8^3 = 8\times 8\times 8 = 512$   \\ \hline
        9 & $9^3 = 9\times 9\times 9 = 729$  \\ \hline
        10 & $10^3 = 10\times 10\times 10 = 1000$  \\ \hline
        \end{tabular}
\end{center}
\end{document}
  • I must admit, that I do not know, what you want to achieve. Could you please explain what width of which row. – Jürgen Apr 7 '17 at 9:54
  • i want to increase width of all rows. – Maths4Sandy Apr 7 '17 at 9:56
  • A row has no with. A column has a width. A row has a height. So what do you want to change? – Manuel Weinkauf Apr 7 '17 at 10:00
  • @Manuel Weinkauf I am sorry. in fact i wanna change height. so sorry – Maths4Sandy Apr 7 '17 at 10:05
  • now how can i make it coreect? – Maths4Sandy Apr 7 '17 at 10:07
5

If you want to increase the rows height while getting the cells contents vertically centred, you can change the values of cellspacetop/bottomlimit, since you already use cellspace. Alternatively, you can load makecell, fix a value for \setcellgapes and make it effective with \makegapedcells.

Note the difference between both ways is that cellspace sets a minimal vertical padding at the top and bottom of the cells in columns with specifiers prefixed by the letter S (or C if you use siunitx), whereas makecell adds a fixed vertical padding:

\documentclass[12pt, a4paper]{article}
\usepackage[top=0.7 in,bottom=0.7 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{parskip}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{makecell}
%reduce top margin
\addtolength{\headsep}{-0.5cm}
%for line spacing
\usepackage{setspace}
\setstretch{0.7}

\begin{document}

\large
\begin{center}
\setlength\cellspacetoplimit{12pt}
\setlength\cellspacebottomlimit{12pt}
    \begin{tabular}{|Sc|Sc|}
        \hline
        \textbf{Natural number} & \textbf{Cube} \\ \hline
        1 & $1^3 = 1\times 1\times 1 = 1$ \\ \hline
        2 & $2^3 = 2\times 2\times 2 = 8$ \\ \hline
        3 & $3^3 = 3\times 3\times 3 = 27$ \\ \hline
        4 & $4^3 = 4\times 4\times 4 = 64$ \\ \hline
        5 & $5^3 = 5\times 5\times 5 = 125$ \\ \hline
        6 & $6^3 = 6\times 6\times 6 = 216$ \\ \hline
        7 & $7^3 = 7\times 7\times 7 = 343$ \\ \hline
        8 & $8^3 = 8\times 8\times 8 = 512$ \\ \hline
        9 & $9^3 = 9\times 9\times 9 = 729$ \\ \hline
        10 & $10^3 = 10\times 10\times 10 = 1000$ \\ \hline
        \end{tabular}
\end{center}
%%%
\begin{center}
\setcellgapes{12pt}
\makegapedcells
    \begin{tabular}{|c|c|}
        \hline
        \textbf{Natural number} & \textbf{Cube} \\ \hline
        1 & $1^3 = 1\times 1\times 1 = 1$ \\ \hline
        2 & $2^3 = 2\times 2\times 2 = 8$ \\ \hline
        3 & $3^3 = 3\times 3\times 3 = 27$ \\ \hline
        4 & $4^3 = 4\times 4\times 4 = 64$ \\ \hline
        5 & $5^3 = 5\times 5\times 5 = 125$ \\ \hline
        6 & $6^3 = 6\times 6\times 6 = 216$ \\ \hline
        7 & $7^3 = 7\times 7\times 7 = 343$ \\ \hline
        8 & $8^3 = 8\times 8\times 8 = 512$ \\ \hline
        9 & $9^3 = 9\times 9\times 9 = 729$ \\ \hline
        10 & $10^3 = 10\times 10\times 10 = 1000$ \\ \hline
        \end{tabular}
\end{center}

\end{document} 

enter image description here

4

Just modify the value of \arraystretch

\documentclass[12pt, a4paper]{article}
\usepackage[top=0.7 in,bottom=0.7 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\usepackage{parskip}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
%reduce top margin
\addtolength{\headsep}{-0.5cm}
%for line spacing
\usepackage{setspace}

\renewcommand{\baselinestretch}{0.7}
\renewcommand{\arraystretch}{1.2} % <--------------
\begin{document}
\large
\begin{center}
    \begin{tabular}{|Sc|Sc|}
        \hline
        \textbf{Natural number} & \textbf{Cube} \\ \hline
        1 & $1^3 = 1\times 1\times 1 = 1$  \\ \hline
        2 & $2^3 = 2\times 2\times 2 = 8$  \\ \hline
        3 & $3^3 = 3\times 3\times 3 = 27$  \\ \hline
        4 & $4^3 = 4\times 4\times 4 = 64$   \\ \hline
        5 & $5^3 = 5\times 5\times 5 = 125$  \\ \hline
        6 & $6^3 = 6\times 6\times 6 = 216$  \\ \hline
        7 & $7^3 = 7\times 7\times 7 = 343$  \\ \hline
        8 & $8^3 = 8\times 8\times 8 = 512$   \\ \hline
        9 & $9^3 = 9\times 9\times 9 = 729$  \\ \hline
        10 & $10^3 = 10\times 10\times 10 = 1000$  \\ \hline
        \end{tabular}
\end{center}
\end{document}
  • Any other way. just for inforamtion – Maths4Sandy Apr 7 '17 at 10:15
  • You may put a \strut into each line. – Jürgen Apr 7 '17 at 10:20
  • 1
    @snehal With the array package, you can use \setlength\extrarowheight{<length>}. – Steven B. Segletes Apr 7 '17 at 10:46
  • @snehal With the stackengine package, you can apply \addstackgap[<length>]{<any particular table cell>} – Steven B. Segletes Apr 7 '17 at 10:48

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.