0

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}
2
  • Could you please copypaste the error message you are getting? It states which control sequence is undefined and where it is ("on line x"). That is essential information.
    – marquinho
    Feb 16 at 10:34
  • 1
    You need \usepackage{multirow} if you want to use \multirow.
    – egreg
    Feb 16 at 10:41

1 Answer 1

4
  • 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)

6
  • Thanks so much for help. Yes, the problem was I used an automatic tool to generate the table, so may be it wasn´t the best option. This is more much clear.
    – Joncarre
    Feb 16 at 13:13
  • @Joncarre, available automatic tools still have lack of AI that be able to compete to human, i.e. a bit experienced table designer 😎. BTW, I'm curious: which from suggested solution you prefer?
    – Zarko
    Feb 16 at 13:20
  • I rather the first option. To be honest, it is easier defining tables like that, where you have all the variables at the beginning of the table and then you just have to add the content.
    – Joncarre
    Feb 18 at 8:22
  • 1
    @Joncarre, yes, package tabularray is very powerful. I use it more and more. Happy TeXing!
    – Zarko
    Feb 18 at 8:28
  • By the way, I am getting an error using your code: Missing the number, treated as zero (I am doing some tests on Overleaf)
    – Joncarre
    Feb 18 at 8:31

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.