0

I'm trying this table - enter image description here

Here's my latex code -

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{test}
\author{Ved}
\date{September 2022}

\begin{document}

\maketitle

\section{Introduction}

\begin{table}[]
\begin{tabular}{|c|l|}
\hline
\begin{tabular}[c]{@{}c@{}}Overall order \\ of reaction\end{tabular} &
  \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Units of rate constant (Remember \\ that time can be given in any units)\end{tabular}} \\ \hline
0 & \begin{tabular}[c]{@{}l@{}}\[\\ \frac{mol}{dm^{3} \times time} =mol\ dm^{-3} \ time^{-1}\\ \]\end{tabular}          \\ \hline
1 & \begin{tabular}[c]{@{}l@{}}\[\\ \frac{1}{time} =time^{-1}\\ \]\end{tabular}                                         \\ \hline
2 & \begin{tabular}[c]{@{}l@{}}\[\\ \frac{dm^{3}}{mol\times time} =dm^{3} \ mol^{-1} \ time^{-1}\\ \]\end{tabular}      \\ \hline
3 & \begin{tabular}[c]{@{}l@{}}\[\\ \frac{dm^{6}}{mol^{2} \times time} =dm^{6} \ mol^{-2} \ time^{-1}\\ \]\end{tabular} \\ \hline
n &
  \begin{tabular}[c]{@{}l@{}}\[\\ (\text{concentration})^{1-n} \times time^{-1}\]\\ can also be written as - \\ \[\left(\frac{mol}{dm^{3}}\right)^{1-n} \times time^{-1}\\ \]\end{tabular} \\ \hline
\end{tabular}
\end{table}

\end{document}

Overleaf is telling me that I've made an error - Error 1 Error 2 Error 3 Can someone please debug my code? I've made an error somewhere and can't seem figure out where it is.

1
  • 1
    why have you all the nested tabular???? Commented Sep 5, 2022 at 17:30

2 Answers 2

0

A small variant of @samcarter_is_at_topanswers.xyz answer. Changed are

  • table style,
  • packages amsmath and siunitx are loaded as tabularray libraries
  • all instruction for table style are collected in table preamble

It works fine with tabularray local installed package version 2022C as well with package version installed now on Overleaf (tested).

\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%
\usepackage{tabularray}
\UseTblrLibrary{amsmath, siunitx}

\begin{document}
    \begin{table}[htbp]
    \centering
\begin{tblr}{
  hlines, vlines,
  colspec = {Q[c, m, mode=math] Q[l, m,  mode=dmath]},
  row{1}  = {mode=text},
  row{2-Z}= {rowsep=5pt}
            }
{Overall order\\ of reaction} 
    & {Units of rate constant\\ (Remember that time can be given in any units)}                     \\
0   & \frac{\unit{mol}}{\unit{dm^{3}} \times \text{time}} =\unit{mol. dm^{-3}} \text{time}^{-1}     \\
1   & \frac{1}{\text{time}} =\text{time}^{-1}                                                       \\
2   & \frac{\unit{dm^{3}}}{\unit{mol}\times \text{time}} =\unit{dm^{3}.mol^{-1}}\text{time}^{-1}    \\
3   & \frac{\unit{dm^{6}}}{\unit{mol^{2}} \times \text{time}} =\unit{dm^{6}.mol^{-2}}\text{time}^{-1} \\
n   & \begin{aligned}
        & (\text{concentration})^{1-n} \times \text{time}^{-1} \text{ can also be written}\\
        & \text{as }\left(\frac{\unit{mol}}{\unit{dm^{3}}}\right)^{1-n} \times \text{time}^{-1}
      \end{aligned}                        \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

(red lines indicate page borders)

1

The main problem is that you can't use \[...\] inside your cells. You could use $\displaystyle ...$ instead, however I think you will get a nicer result with the tabularray package.

You are also using \text{...} in your code, but the amsmath package is missing in your preamble.

And finally, you might want to have a look at the siunitx package to correctly set your units in upright font.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{siunitx}

\title{test}
\author{Ved}
\date{September 2022}

\usepackage{tabularray}

\begin{document}

\maketitle

\section{Introduction}

\begin{table}[htbp]
\begin{tblr}{
  colspec={Q[c]X[mode=dmath]},
  vlines,
  hlines,
  cells={valign=m}
}
Overall order of reaction & \SetCell{mode=text} Units of rate constant (Remember that time can be given in any units)\\ 
0 &  \frac{\unit{mol}}{\unit{dm^{3}} \times \text{time}} =\unit{mol. dm^{-3}} \text{time}^{-1}       \\
1 & \frac{1}{\text{time}} =\text{time}^{-1}                                         \\ 
2 & \frac{\unit{dm^{3}}}{\unit{mol}\times \text{time}} =\unit{dm^{3}.mol^{-1}}\text{time}^{-1}      \\ 
3 & \frac{\unit{dm^{6}}}{\unit{mol^{2}} \times \text{time}} =\unit{dm^{6}.mol^{-2}}
\text{time}^{-1} \\ 
n & (\text{concentration})^{1-n} \times \text{time}^{-1} $ can also be written as $ \displaystyle \left(\frac{\unit{mol}}{\unit{dm^{3}}}\right)^{1-n} \times \text{time}^{-1} \\ 
\end{tblr}
\end{table}

\end{document}

enter image description here

5
  • Unfortunately Overleaf still has installed too old version of tabularray package, so mode=dmath instruction doesn't work. as expected (cells with math are black). I hope, that they will update their installation until the end of the (this) year ...
    – Zarko
    Commented Sep 5, 2022 at 21:41
  • @Zarko They just updated to TL2022 Commented Sep 5, 2022 at 21:43
  • 1
    Really? I just try your nice code (+1) but it still not work as expected. I'm use Overleaf very rare, so I'm not familiar with it. What I should do, that I will get access to recent installed Overleaf?
    – Zarko
    Commented Sep 5, 2022 at 21:46
  • @Zarko New projects will automatically use TL22, for older ones you can select it from the sidebar Commented Sep 6, 2022 at 7:55
  • Thank you very much. As you can see from my answer, I figured out this. Now your and mine code can be compiled on Overleaf too. Thank you for information!
    – Zarko
    Commented Sep 6, 2022 at 8:02

You must log in to answer this question.

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