First of all, thank you for trying to help! This is the problem that I have:
I am trying to create a table that will list a bunch of commands and their description. For that, I need to be able to use multicolumn and multirow features. Also, toprule, midrule, and bottomnrule.
The problem is that the table is longer than one page so I need it to continue on the next page. I found about the longtable package but I cannot seem to be able to figure how to incorporate all of the features I need and still make it work.
I will attach my code for the regular table. Can someone please help me convert it to longtable and keep the formatting the same? I would really appreciate it if someone can help me and also explain how it works because I want to learn it for future use. Big thank you!!!
My Code
\documentclass[10pt,english, openany, twoside]{book}
\usepackage[table]{xcolor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Loading packages that alter the style
\usepackage[]{graphicx}
\usepackage[]{color}
\usepackage{alltt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
% Set page margins
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
% Package used for placeholder text
\usepackage{lipsum}
% Prevents LaTeX from filling out a page to the bottom
\raggedbottom
% Adding both languages
\usepackage[english]{babel}
% All page numbers positioned at the bottom of the page
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.0pt}
\fancyhead[LE,RO]{}
\fancyhead[RE,LO]{}
\fancyhead[CE,CO]{}
\fancyfoot[CE,CO]{\thepage}
% Adds table captions above the table per default
\usepackage{float}
%\floatstyle{plaintop}
%\restylefloat{table}
% Adds space between caption and table
\usepackage{caption}
\captionsetup[table]{position=bottom}
% Adds hyperlinks to references and ToC
\usepackage{hyperref}
\hypersetup{hidelinks,linkcolor = black} % Changes the link color to black and hides the hideous red border that usually is created
%Document Styling% <---------%
%%%%%%%%%%%%%%%%%%
\usepackage{float}
\usepackage{array}
\usepackage{hhline}
\usepackage{arydshln}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{framed}
\usepackage{mdframed} % This frames the sections. However, a command \begin{mdframed}[options] is needed
\usepackage{multicol} % To change column separation use: \setlength{\columnsep}{-3in}
\usepackage{enumitem} % This package removes the indent on the enumeated list. Allows for the command [Leftmargin=*]
%%%%%%%%%%%%%%%%%%
%Graphics% <---------%
%%%%%%%%%%
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xcolor}
%%%%%%%%%%
%Font% <---------%
%%%%%%
\usepackage[T1]{fontenc}
\usepackage{textcomp} %
\usepackage{hyperref}
\usepackage{url}
\urlstyle{same}
%%%%%%
%Mathematics% <---------%
%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{physics}
\usepackage{siunitx}
%For Table%
%%%%%%%%%%%
\usepackage{booktabs}
\sisetup{
round-mode = places, % Rounds numbers
round-precision = 2, % to 2 places
}
\usepackage{colortbl}
\usepackage{xfrac}
\definecolor{Gray}{gray}{0.85}
%dashed line
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\definecolor{codegray}{gray}{0.9}
\usepackage{longtable}
\usepackage{booktabs}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Starts the document
\begin{document}
\begin{table}[h!]
\centering
\begin{tabular}{llll}
\toprule
\multicolumn{4}{c}{\textbf{Serial Command List}} \\
\toprule
\textbf{Name} & \textbf{Command} & \textbf{Reply} & \textbf{Description} \\
\midrule
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
\hdashline
%
Set Power & \texttt{\$P,n} & \texttt{\$Pr} & \noindent\begin{tabular}{@{}l}
n = power percentage\\
\phantom{n = }\textbf{Note}: Up to 3 digits and 2 decimal places. \\\\
e.g. \colorbox{codegray}{\texttt{\$P,57.5}} sets power to 57.5\% \\\\
r = ERROR CODE (0 if no error)
\end{tabular} \\
%
\bottomrule
\end{tabular}
\caption{Serial Command List}
\label{tab:command-list}
\end{table}
\end{document}
Output
multirow
. You mention it in your question but the code you show des not even load themultirow
package. Please explain.longtable
with dashed horizontal lines fromarydshln
and also loadhyperref
, please be aware that the correct load order to packages is\usepackage{longtable}\usepacakge{hyperref}\usepackage{arydshln}
. (See also: section "9.1.4 arydshln, longtable" of thehyperref
manual.)