1

I searched how to create a nested table but I didn't find a solution that works for me. What I need is to create this table.

enter image description here

Any one can help please?

  • 1
    Welcome to TeX.SX, please show us, what you've got so far. A compilable example would be the best, not just a picture. Have a look here: tex.meta.stackexchange.com/questions/228/… – DG' Apr 13 '18 at 10:08
  • tex.stackexchange.com/questions/40561/… shows several ways to do it. – lblb Apr 13 '18 at 10:10
  • 1
    Where would you have a nested table? – Bernard Apr 13 '18 at 10:12
  • @Bernard each module can has many scenarios. For each scenarios I have ID + scenarios + priority – Amir Choubani Apr 13 '18 at 10:21
  • Must I understand the scenario with highest priority has a blue background, and it does not necessarily follow the scheme ‘each other subrow has a blue background’? – Bernard Apr 13 '18 at 10:25
3

In my opinion, your table example is more a merge/span of several rows from the column "ID scénario" than a nested table. In Excel, which seems to be your original model, this would be the equivalent of merge.

For documentation, this page provides an example, using the multirow package, under the section "Multiple rows". Let me know if you need a full example, I'll add it here below.

Bonne chance, Xavier

Edit 1 - Example 1

And here it is, this produce a similar table, with the first 2 columns being merges by rows, according to your example.

\documentclass[11pt]{article}
\usepackage{multirow}
\usepackage{tabulary}
% \usepackage{polyglossia}
% \setmainlanguage{french}

\begin{document}
\begin{table}
\begin{tabulary}{\linewidth}{|c|l|l|L|L|}
    \hline
    ID Module & Module & ID Scenario & Scenario & Priorite \\
    \hline
    1 & Gestion de l'inscription & 1.1 & En tant que & Elevee \\    
    \hline  
    \multirow{2}{*}{2} & \multirow{2}{*}{Gestion de l'inscription} & 2.1 & En tant que & Elevee \\
    & & 2.2 & En tant que & Elevee \\   
    \hline
\end{tabulary}
\end{table}

\end{document}
  • Yes, if possible I need a full example. – Amir Choubani Apr 13 '18 at 10:18
  • the tabluraly influenced the width of subsections and subsubsections title. Is there a way to reset the title width – Amir Choubani Apr 15 '18 at 13:13
2

Here is a solution without multirow, using the tabularx environmen, and a slightly different layout with makecell:

\documentclass[11pt, french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[showframe]{geometry}
\usepackage[table, svgnames]{xcolor}
\usepackage{ tabularx, makecell}
\usepackage{ragged2e}

\begin{document}
\begin{table}
\centering\sffamily
\setlength{\extrarowheight}{3pt}
\setlength{\tabcolsep}{3pt}
\renewcommand{\theadfont}{\normalsize\bfseries\color{white}}
\rowcolors{3}{white}{AliceBlue}
\arrayrulewidth = 0.8pt
\arrayrulecolor{SkyBlue}
\begin{tabularx}{\linewidth}{|c|>{\RaggedRight\hsize=0.75\hsize}X|c|>{\RaggedRight\hsize=1.25\hsize}X|l|}
    \hline
 \rowcolor{SteelBlue} \thead{ID\\ Module} & \thead{Module} & \thead{ID\\ Scénario} & \thead{Scénario} & \thead{Priorité}\\
    \hline
    1 & Gestion de l'inscription & 1.1 & En tant qu’utilisateur, je peux créer un compte pour accéder à l’application & Élevée \\
    \hline
    2 & Gestion d’authentification & 2.1 & En tant qu’utilisateur, je peux m’authentifier pour accéder à mon compte& Élevée \\
\cellcolor{white} & \cellcolor{white}& 2.2 & En tant qu’utilisateur, je peux m’authentifier pour accéder à mon compte & Élevée \\
 \hline
3 & Gestion des comptes & 3.1 & En tant qu’utilisateur, je veux gérer les utilisateurs de la plate-forme & Élevée \\
 \cellcolor{white} & \cellcolor{white}& 3.2 & En tant qu’utilisateur, je veux gérer mon compte & Élevée \\
 \hline
 4 & Gestion des produits & 4.1 & En tant qu’utilisateur, je veux con\-sulter les produits de Marketplace & Élevée \\
 \cellcolor{white} & \cellcolor{white} & 4.2 & En tant qu’utilisateur, je veux modifier les produits de Marketplace & Élevée \\
   & &4.3 & En tant qu’utilisateur, je veux supprimer les produits de Marketplace & Élevée \\
\hline
\end{tabularx}
\end{table}

\end{document} 

enter image description here

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.