Multirow undefined control sequence

multirowundefined

I am having some problems using multirow. I'm not sure if it's due to the qcr font as I'm just learning LaTeX. Could someone help me identify the problem? I have created a simple document to reproduce the problem:

\documentclass[preprint]{elsarticle}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{epsfig}
\usepackage{alltt}
\usepackage{fixme}
\usepackage[table,xcdraw]{xcolor}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{enumerate}
\usepackage[T1]{fontenc}
\usepackage{xr}
\usepackage{graphics}
\usepackage{listings}
\usepackage{tcolorbox}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage[ruled, lined, linesnumbered, commentsnumbered, longend]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{booktabs}
\usepackage{verbatim}
\journal{Journal of Computational Science}
\bibliographystyle{elsarticle-num}
\begin{document}
\begin{frontmatter} 

% ----- Title -----
\title{Blah, blah, blah\tnoteref{t1}}

% ---------- Abstract ----------
\begin{abstract}
Blah, blah, blah
\end{abstract}
\end{frontmatter}

% ---------- Table ----------
\begin{table}[]
\scriptsize
\begin{center}
\caption{The most commonly used variables for PRNG}
\begin{tabular}{|c|l|p{4.7cm}|}
\hline
\rowcolor[HTML]{EFEFEF} 
{\color[HTML]{000000} \textbf{Based on}} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} \textbf{Name}}} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} \textbf{Description}}} \\ \hline
                                 & {\fontfamily{qcr}\selectfont block.coinbase}                     & Address of the miner who mined the current block\\ \cline{2-3} 
                                 & {\fontfamily{qcr}\selectfont block.difficulty}                   & Relative measure of how difficult it was to find the block\\ \cline{2-3} 
                                 & {\fontfamily{qcr}\selectfont block.gaslimit}                     & Maximum gas consumption for transactions within the block\\ \cline{2-3} 
\multirow{-5}{*}{Block variable} & {\fontfamily{qcr}\selectfont block.number}                       & Height of current block\\ \cline{2-3} 
                                 & {\fontfamily{qcr}\selectfont block.timestamp}                    & When the block was mined\\ \hline
                                 & {\fontfamily{qcr}\selectfont block.blockhash(block.number)}      & Blockhash of the current block\\ \cline{2-3} 
                                 & {\fontfamily{qcr}\selectfont block.blockhash(block.number - 1)}  & Blockhash of the last block\\ \cline{2-3} 
\multirow{-3}{*}{Blockhash}      & {\fontfamily{qcr}\selectfont block.blockhash()}                  & Blockhash of a block that is at least 256 blocks older than the current one\\ \hline
\end{tabular}
\end{center}
\end{table}

\bibliography{references}
\end{document}

Best Answer

  • you need to clean-up your preamble (remove all twice loaded packages, move hyperref on the end preamble)
  • your table can be significantly simplified:
    • by use of (relative new package) tabularray
\documentclass[preprint]{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[xcdraw]{xcolor}
\usepackage{tabularray}

\begin{document}

% ---------- Table ----------
    \begin{table}[htb]
    \small
    \caption{The most commonly used variables for PRNG}
\begin{tblr}{hline{1,2,Z} = 0.8pt, hline{3-Y} = 0.2pt, vlines,
             colspec = {Q[c,m, 3.4em]
                        Q[l,m, font=\fontfamily{qcr}]
                        X[l,m]},
             colsep  = 4pt,
             row{1}  = {font=\bfseries, bg=gray!30}
             }

Based on
    &   Name    &   Description                             \\
\SetCell[r=5]{c}    Block variable
    &   block.coinbase
                &   Address of the miner who mined the
                    current block                           \\
    &   block.difficulty
                &   Relative measure of how difficult it was
                    to find the block                       \\
    &   block.gaslimit
                &   Maximum gas consumption for transactions
                    within the block                        \\
    &   block.number
                &   Height of current block                 \\
    &   block.timestamp
                &   When the block was mined                \\
%
\SetCell[r=3]{c}    Block\-hash
    &   block.blockhash(block.number)
                &   Blockhash of the current block          \\
    &   block.blockhash(block.number\,-\,1)
                &   Blockhash of the last block             \\
    &   block.blockhash()
                &   Blockhash of a block that is at least
                    256 blocks older than the current one   \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

  • by use makecell, multirow and tabularx package:
\documentclass[preprint]{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[table, xcdraw]{xcolor}
\usepackage{ragged2e}                       % new
\usepackage{booktabs, 
            makecell, multirow, tabularx}   % new
\renewcommand\theadfont{\bfseries}


\begin{document}

% ---------- Table ----------
    \begin{table}[htb]
    \caption{The most commonly used variables for PRNG}
    \small
    \renewcommand\tabularxcolumn[1]{m{#1}}
    \renewcommand\arraystretch{1.1}
\begin{tabularx}{\linewidth}{|>{\centering}p{3.4em}
                             |>{\fontfamily{qcr}\selectfont}l
                             |>{\RaggedRight}X|}
    \Xhline{0.8pt}
\thead{Based\\ on}
    & \thead{Name}  & \thead{Description}                   \\
    \Xhline{0.8pt}
\multirow{10}{=}{Block variable}
    &   block.coinbase
                &   Address of the miner who mined the
                    current block                           \\
    \cline{2-3}
    &   block.difficulty
                &   Relative measure of how difficult it was
                    to find the block                       \\
    \cline{2-3}
    &   block.gaslimit
                &   Maximum gas consumption for transactions
                    within the block                        \\
    \cline{2-3}
    &   block.number
                &   Height of current block                 \\
    \cline{2-3}
    &   block.timestamp
                &   When the block was mined                \\
    \hline
%
\multirow{6}{=}{Block\-hash}
    &   block.blockhash(block.number)
                &   Blockhash of the current block          \\
    \cline{2-3}
    &   block.blockhash(block.number\,-\,1)
                &   Blockhash of the last block             \\
    \cline{2-3}
    &   block.blockhash()
                &   Blockhash of a block that is at least
                    256 blocks older than the current one   \\
    \Xhline{0.8pt}
\end{tabularx}
    \end{table}
\end{document}

enter image description here

(red lines indicate text area border)

Related Question