I'm trying to create a table that looks like this:
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.
I'm trying to create a table that looks like this:
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.
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).
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
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}