1

I'm trying to create a table that looks like this:

enter image description here

I'm using the RevTex 4.2 Template. I've been reading this thread but am a beginner with Latex and am not sure how to modify it to make the table I want.

  • 1
    Welcome to TeX.SE :) // May I suggest this read for you? https://en.wikibooks.org/wiki/LaTeX . Once you've some more basic knowledge about Latex, things will become easier for you. At the moment, you've chosen a task too much, in my understanding. – MS-SPO Nov 12 '21 at 16:39

2 Answers2

2

With {NiceTabular} of nicematrix.

\documentclass{revtex4-2}
\usepackage{nicematrix}
\usepackage{geometry}
\usepackage{caption}

\begin{document}

\begin{table} \small \begin{NiceTabular}{ccwc{1cm}wc{1cm}cc}[hvlines,cell-space-limits=2pt] \RowStyle[bold]{} Assumption & & \multicolumn{2}{c}{Double slit} & Right slit & Left slit \ $a=#$ mm & \Block{2-1}{$\lambda$ [nm] = } & # & \Block{2-1}{#} & # & # \ $d=#$ mm & & # & & \Block{1-2}{n/a} \ $\lambda = #$ mm & $a$ [mm] = & \Block{1-2}{#} & & # & # \end{NiceTabular} \end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250
  • Thank you! That worked well. The only problem is I'm getting an error with the line \RowStyle[bold]{}: "Package nicematrix Error: As for now, there is only three keys available." But this isn't a big problem since I can use \textbf{ } for the column titles. – Jaqueline Bernard Nov 13 '21 at 18:54
  • I think that you have not the latest version of nicematrix. – F. Pantigny Nov 13 '21 at 19:15
  • How can I get the latest version? I'm using Overleaf. – Jaqueline Bernard Nov 13 '21 at 19:56
  • Overleaf has not the latest version of nicematrix. You should upload the latest version of the file nicematrix.sty in the repertory of your Overleaf project. You can find that file on the SVN server of TeXLive: www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty – F. Pantigny Nov 13 '21 at 20:22
  • Ok thanks! @F. Pantigny – Jaqueline Bernard Nov 13 '21 at 23:26
2

With tabularray:

\documentclass{revtex4-2}
\usepackage{geometry}
\usepackage{tabularray}
\usepackage{caption}

\usepackage{lipsum}

\begin{document} \lipsum[66] \begin{table}[ht] \centering \begin{tblr}{width=0.8\linewidth, hlines=0.4pt, vlines=0.4pt, colspec = {l *{5}{X[c,m]}}, colsep = 4pt, row{1} = {font=\small\bfseries}, rowsep = 3pt } Assumption & & \SetCell[c=2]{c} Double slit
& & Right slit & Left slit \ $a=#$ mm & \SetCell[r=2]{c} $\lambda$ [nm] = & # & \SetCell[r=2]{c} #
& # & # \ $d=#$ mm & & # & & \SetCell[c=2]{c} n/a
& \ $\lambda = #$ mm & $a$ [mm] =& \SetCell[c=2]{c} n/a & & # & # \ \end{tblr} \end{table} \end{document}

enter image description here

Zarko
  • 296,517