# Fitting the line within Cell in a table

How can I fit the line inside the cell

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{makecell, cellspace, caption}
\usepackage[table, svgnames, dvipsnames]{xcolor}
\begin{document}

\begin{table}[h]
\begin{center}
\label{1}
\scriptsize
\renewcommand{\arraystretch}{2.4}
\begin{tabular}{|>{\centering\arraybackslash}p{0.7\textwidth}|
>{\centering\arraybackslash}p{0.1\textwidth}|
>{\centering\arraybackslash}p{0.1\textwidth}|
}
\hline\hline
\rowcolor{Gainsboro!60}
Course Learning Outcomes (CLO)$^\star$ &Question &Grade \\
\hline
\multirow{3}{*}{
1- Understand complex plane and the concepts of complex exponential functions, phasors, impedances and admittances.}
& 1&1 \\ \cline{2-3}
& 2 & 1  \\ \cline{2-3}
& 3 &1   \\ \cline{2-3}
& 4 &1   \\ \cline{2-3}
& 5& 1 \\ \cline{2-3}

\hline
\end{tabular}
\end{center}

\end{table}
\end{document}

• Try with \multirow{3}{=}{....} instead. Oct 28, 2020 at 15:17
• Thanks, it worked Oct 28, 2020 at 15:25

To make a \multirow cell as wide as its surrounding column, use = instead of *. The * makes the multirow cell as wide as its contents, hence the overflow that you observe. If you also want to make sure the contents are vertically centered with respect to the adjacent column, you can use \multirow{5}{*}{...}.

In the following MWE, I have also made some more suggestions on how to improve the code and its output:

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{makecell}
\usepackage[column=0]{cellspace}
\usepackage{caption}
\usepackage[table, svgnames, dvipsnames]{xcolor}

\usepackage{tabularx}
\setlength{\cellspacetoplimit}{\tabcolsep}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}
\begin{document}

\begin{table}[h]
%        \begin{center} % better use \centering instead. The center environment adds vertical white space.
%        \label{1} % useless without a corresponding caption
%        \scriptsize
%        \renewcommand{\arraystretch}{2.4} % replaced with cellspace to ensure vertically centered cell contents
\begin{tabularx}{\textwidth}{|>{\centering\arraybackslash}X|
0{wc{0.125\textwidth}}| % from the array package that you already load
0{wc{0.125\textwidth}}|
}
\hline\hline
\rowcolor{Gainsboro!60}
Course Learning Outcomes (CLO)$^\star$ &Question &Grade \\
\hline
\multirow{6}{=}{
1- Understand complex plane and the concepts of complex exponential functions, phasors, impedances and admittances.}
& 1&1 \\ \cline{2-3}
& 2 & 1  \\ \cline{2-3}
& 3 &1   \\ \cline{2-3}
& 4 &1   \\ \cline{2-3}
& 5& 1 \\ \cline{2-3}

\hline
\end{tabularx}
%        \end{center}

\end{table}
\end{document}


A small variation of the nice @lenardiis answer (+1):

• added is possibility to hyphenate text in \multirow cells
• used \Xhline{...} defined in makecell package for horizontal rules in table
\documentclass[12pt]{article}
\usepackage{ragged2e}       % new
\hyphenation{im-ped-ance im-ped-ances}  % <--- (source: https://www.hyphenator.net/en/word/)
\usepackage{array, makecell, multirow, tabularx}
\usepackage[column=0]{cellspace}
\setlength\cellspacetoplimit{\tabcolsep}
\setlength\cellspacebottomlimit{\cellspacetoplimit}
\usepackage{caption}
\usepackage[table, svgnames, dvipsnames]{xcolor}

\begin{document}
\begin{table}[ht]
\renewcommand\multirowsetup{\RaggedRight}   % <--- new
\begin{tabularx}{\textwidth}{|>{\Centering}X  | % <--- changed
wc{0.12\textwidth} |
0{wc{0.12\textwidth}}|
}
\Xhline{1pt}
\rowcolor{Gainsboro!60}
Course Learning Outcomes (CLO)$^\star$
&    Question   &   Grade   \\
\Xhline{0.8pt}
\multirow{6}{=}{%  <---
1- Understand complex plane and the concepts of complex exponential functions, phasors, impedances and admittances.}
&   1           &   1       \\  \cline{2-3}
&   2           &   1       \\  \cline{2-3}
&   3           &   1       \\  \cline{2-3}
&   4           &   1       \\  \cline{2-3}
&   5           &   1       \\  \cline{2-3}
\Xhline{1pt}
\end{tabularx}
\end{table}
\end{document}