2

Sorry for asking this question even though asked multiple times. But I can't seem to do it. I'm new to LaTeX.

Here is the code and the table currently.

\documentclass[11pt, a4paper, notitlepage]{article}
\usepackage{array}
\usepackage{multirow}

\begin{table}[h]
\centering
\begin{tabular}{|l|c|c|c|c|}
\hline
\multirow{2}{*}{\parbox{8em}{Low and high voltage levels with 20\% duty cycle}} & \multicolumn{2}{c|}{voltage readings} & \multicolumn{2}{l|}{calculated values}  \tabularnewline
\cline{2-5}
    & DC & RMS & DC & RMS \tabularnewline
\hline
    &    &     &    & \tabularnewline
\hline
    &    &     &    & \tabularnewline
\hline
    &    &     &    & \tabularnewline
\hline
\end{tabular}
\end{table}

Current table

As you can see above, the long sentence at the top left can't fit into cell. I want to make this table like this.

Tabel I want

I appreciate any help. Thanks!

0

2 Answers 2

1

With use of makecell for adding vertical spaces around cells' contents and reducing lines spread in the first columns by use of \linespread{0.6}\selectfont:

enter image description here

Writing values in cells I left to you.
\documentclass[11pt, a4paper, notitlepage]{article}
\usepackage{array, makecell, multirow}
\usepackage{siunitx}

\begin{document}
    \begin{table}[ht]
    \centering
\setlength\tabcolsep{3pt}
\setcellgapes{3pt}
\makegapedcells
\renewcommand\multirowsetup{\centering} % <---
\begin{tabular}{|>{\linespread{0.6}\selectfont}p{8em}|c|c|c|c|}
\hline
\multirow{2}{=}{Low and high voltage levels with \SI{20}{\%} duty cycle} 
    & \multicolumn{2}{c|}{voltage readings} 
            & \multicolumn{2}{l|}{calculated values}  \tabularnewline
\cline{2-5}
    & DC    & RMS & DC & RMS    \tabularnewline
\hline
    &       &     &    &        \tabularnewline
\hline
    &       &     &    &        \tabularnewline
\hline
    &       &     &    &        \tabularnewline
\hline
\end{tabular}
    \end{table}
\end{document}
1

You can solve your probem with cellspace, which enables you to defines a minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S (or C if you load siunitx).

\documentclass[11pt, a4paper, notitlepage]{article}
\usepackage{array}
\usepackage{multirow}%
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{8pt}
\setlength{\cellspacebottomlimit}{8pt}

\begin{document}

\begin{table}[h]

\centering
\begin{tabular}{| >{\centering\arraybackslash}m{8em}|Sc|Sc|Sc|Sc|}
\hline
\multirow{1.8}{=}{\centering Low and high voltage levels with 20\% duty cycle} & \multicolumn{2}{Sc|}{voltage readings} & \multicolumn{2}{Sl|}{calculated values} \tabularnewline
\cline{2-5}
    & DC & RMS & DC & RMS \tabularnewline
\hline
    & & & & \tabularnewline
\hline
    & & & & \tabularnewline
\hline
    & & & & \tabularnewline
\hline
\end{tabular}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .