6

I have copied what I wrote in LaTeX and I will also attach a picture of what I want to achieve.

Desired result:

Image

What I wrote so far:

\begin{center}
\begin{tabular}{ |p{1.5cm}||p{1.5cm}|p{1.5cm}|p{1.5cm}||p{1.5cm}| }
\hline
\multicolumn{5}{|c|}{Lepton Classification} \\
\hline
$l$ & $Q$ & $L_e$ & $L_\mu$ & $L_\tau$\\
\hline
$e$  & -1 & 1 & 0 & 0 \\
$\nu_e$ & 0 & 1 & 0 & 0\\
\hline
$\mu$ & -1 & 0 & 1 & 0 \\
$\nu_\mu$ & 0  & 0 & 1 & 0\\
\hline
$\tau$ & -1 & 0 & 0 & 1 \\
$\nu_\tau$ & 0  & 0 & 0 & 1\\
\hline
\end{tabular}
\end{center}

I looked up several posts. However, I could not adjust the solutions to my problem.

1
  • Quick suggestion, please use \usepackage{multirow} and \multirow....
    – MadyYuvi
    Sep 20 at 9:33
6

Here is a way to do that with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{center}
\begin{NiceTabular}{ccccc}[first-row,first-col,vlines,cell-space-limits=3pt]
  & \Block{1-5}{Lepton Classification} \\ \Hline
\RowStyle[bold]{}
  & $l$ & $Q$ & $L_e$ & $L_\mu$ & $L_\tau$ \\ \Hline
\Block[l]{2-1}{First generation\hspace*{3mm}}
  & $e$  & -1 & 1 & 0 & 0 \\
  & $\nu_e$ & 0 & 1 & 0 & 0 \\ \Hline
\Block[l]{2-1}{Second generation\hspace*{3mm}}
  & $\mu$ & -1 & 0 & 1 & 0 \\
  & $\nu_\mu$ & 0  & 0 & 1 & 0 \\ \Hline
\Block[l]{2-1}{Third generation\hspace*{3mm}}
  & $\tau$ & -1 & 0 & 0 & 1 \\
  & $\nu_\tau$ & 0  & 0 & 0 & 1 \\ \Hline
\CodeAfter [sub-matrix/left-xshift=2.5mm,sub-matrix/extra-height=-4pt]
  \SubMatrix{\lbrace}{2-1}{3-1}{.}
  \SubMatrix{\lbrace}{4-1}{5-1}{.}
  \SubMatrix{\lbrace}{6-1}{7-1}{.}
\end{NiceTabular}
\end{center} 

\end{document}

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

Output of the above code

7
  • Thanks you very much for your help! Sep 20 at 16:31
  • BTW, what do you mean by several compilations? I tried it and I get some errors, like "undefined control sequence". If you happen to know how it can be solved, it would be very useful ! Sep 20 at 17:10
  • During the first compilation, some informations are written in the aux file. They are used at the next compilation, etc. Some tools, such as latexmk, directly do the right number of compilations. If you use Overleaf, the right number of compilations is done. Sep 20 at 17:22
  • Remark about Overleaf: 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 Sep 20 at 17:23
  • 1
    @somerandomguest: I have modified my answer. Sep 23 at 16:38
6

A solution with NiceArray of nicematrix

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{nicematrix}
\begin{document}
\[\NiceMatrixOptions{exterior-arraycolsep}
\begin{NiceArray}{c@{\hspace*{2em}}cccccc}[cell-space-limits=3pt]
&& \Block{1-5}{\text{Lepton Classification}} &&&& \\
&& l & Q & L_e & L_\mu & L_\tau \\
\Block{2-1}{\text{First generation}} && e  & -1 & 1 & 0 & 0 \\
&& \nu_e & 0 & 1 & 0 & 0 \\
\Block{2-1}{\text{Second generation}} && \mu & -1 & 0 & 1 & 0 \\
&& \nu_\mu & 0  & 0 & 1 & 0 \\
\Block{2-1}{\text{Third generation}} && \tau & -1 & 0 & 0 & 1 \\
&& \nu_\tau & 0  & 0 & 0 & 1
\CodeAfter
\begin{tikzpicture}
\foreach \x in {3,5,7} \draw (\x-|3) -- (\x-|last);
\foreach \x in {4,5,6,7} \draw (2-|\x) -- (last-|\x);
\draw (2-|3) rectangle (last-|last);
\draw[decoration={brace}, decorate] ([shift={(-4pt,2pt)}]5-|2) -- ([shift={(-4pt,-2pt)}]3-|2);
\draw[decoration={brace}, decorate] ([shift={(-4pt,2pt)}]7-|2) -- ([shift={(-4pt,-2pt)}]5-|2);
\draw[decoration={brace}, decorate] ([shift={(-4pt,2pt)}]9-|2) -- ([shift={(-4pt,-2pt)}]7-|2);
\end{tikzpicture}
\end{NiceArray}
\]
\end{document}

enter image description here

3
  • Hi, perhaps it is better if you shift, a bit, to the right the curly brackets.
    – Sebastiano
    Sep 20 at 11:41
  • 1
    @Sebasiano I agree. Thank you for the comment. It is easy to adjust.
    – polyn
    Sep 20 at 11:53
  • @polyn , thank you so much for your solution, it's great! But it needs so much knowledge, bruhh! Still have to learn a lot! Sep 20 at 16:36
5

I propose this solution with basic tools – the eqparbox and bigdelim packages:

\documentclass{article}
\usepackage{geometry}
\usepackage{bigdelim}
\usepackage{eqparbox}

\begin{document}

\begin{center}
\setlength{\extrarowheight}{3pt}
\begin{tabular}{l |wc{1.2cm}||wc{1.2cm}|wc{1.2cm}|wc{1.2cm}||wc{1.2cm}| }
\cline{2-6}
 & \multicolumn{5}{|c|}{Lepton Classification} \\
\cline{2-6}
& $l$ & $Q$ & $L_e$ & $L_\mu$ & $L_\tau$\\
\cline{2-6}
\ldelim\{{2}{*}[\eqparbox{A}{First generation}] & $e$ & -1 & 1 & 0 & 0 \\
 & $\nu_e$ & 0 & 1 & 0 & 0\\[1ex]
\cline{2-6}
\ldelim\{{2}{*}[\eqparbox{A}{Second generation\hspace*{1.5em}}] & $\mu$ & -1 & 0 & 1 & 0 \\
 & $\nu_\mu$ & 0 & 0 & 1 & 0\\[1ex]
\cline{2-6}
\ldelim\{{2}{*}[\eqparbox{A}{Third generation}] & $\tau$ & -1 & 0 & 0 & 1 \\
 & $\nu_\tau$ & 0 & 0 & 0 & 1\\
\cline{2-6}
\end{tabular}
\end{center}

\end{document} 

enter image description here

4
  • 1
    A warm thanks for the edit, @Sebastiano! Once more, I forgot to check if everything was OK…
    – Bernard
    Sep 20 at 11:35
  • We here are a great community...and it is a very pleasure to help everyone. :-)
    – Sebastiano
    Sep 20 at 11:37
  • @Bernard , Thank you so much for your solution! Could you please tell me how to adjust the braces a bit more, so that they are shifted a bit downwards? (Since now they do not exactly point where they are supposed to, they are slightly shifted upwards) Sep 20 at 16:33
  • 2
    At the end of each group, I added a vertical spacing of 1ex (\\[1ex]). You may change this value, or even suppress these spacings (in this case, each brace touches the next one)? Other tool: cheat a bit and use decimal values in \ldelim,, e.g. \ldelim\{ {2.25}{*}{…}
    – Bernard
    Sep 20 at 17:49
0

i used the \multirow commands (from the multirow package) on a 6th column on the left of your table (for your generations comments). using \cline{2-6} instead of \hline prevent from having horizontal lines above and below the generations cases.

I have also put your title (Lepton classification) into a different table so it is not surrounded by vertical lines like the rest of your table.

My code :

\begin{table}
\centering
\begin{tabular}{m{4cm}m{1cm}m{1cm}m{1cm}m{1cm}m{1cm}}
& \multicolumn{5}{c}{Lepton Classification} \\
\end{tabular}
\begin{tabular}{m{4cm}|m{1cm}|m{1cm}|m{1cm}|m{1cm}|m{1cm}|}
\cline{2-6}
& $l$ & $Q$ & $L_e$ & $L_\mu$ & $L_\tau$\\
\cline{2-6}
\multirow{2}{*}{First Generation} & $e$  & -1 & 1 & 0 & 0 \\
& $\nu_e$ & 0 & 1 & 0 & 0\\
\cline{2-6}
\multirow{2}{*}{Second Generation} & $\mu$ & -1 & 0 & 1 & 0 \\
& $\nu_\mu$ & 0  & 0 & 1 & 0\\
\cline{2-6}
\multirow{2}{*}{Third Generation} & $\tau$ & -1 & 0 & 0 & 1 \\
& $\nu_\tau$ & 0  & 0 & 0 & 1\\
\cline{2-6}
\end{tabular}
\end{table}

Result : enter image description here

3
  • I don't know about the brackets though. Sep 20 at 9:58
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 20 at 10:00
  • Hi @PierrickMorin ! Thank you for your answer! My main problem is unfortunately the braces. Let's wait for someone to answer it and it will be useful for both of us:) Sep 20 at 10:13

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.