1

How can I make the following table in my latex document.

enter image description here

This is exactly what I want, this is what I have done so far

\usepackage[utf8]{inputenc}

\PassOptionsToPackage{es-tabla,spanish,es-lcroman,es-noquoting}{babel} \usepackage{float} \usepackage{anysize}

\marginsize{2cm}{2cm}{2cm}{2cm}

\begin{document}

\section{Introduction}

\begin{table}[H] \begin{tabular}{l|l|l|l|} \hline \multicolumn{1}{|c|}{\textbf{Id}} & \multicolumn{1}{c|}{\textbf{Tipo de riesgo}} & \multicolumn{1}{c|}{\textbf{Riesgos}} & \multicolumn{1}{c|}{\textbf{Probabilidad}} \ \hline \multicolumn{1}{|l|}{} & & & \ \hline \multicolumn{1}{|l|}{} & \multirow{5}{*}{\begin{tabular}[c]{@{}l@{}}Entorno de desarrollo \y tecnologías\end{tabular}} & \begin{tabular}[c]{@{}l@{}}Las herramientas de desarrollo no funcionan\ como se esperaba\end{tabular} & Probable \ \cline{1-1} \cline{3-4}

\multicolumn{1}{|l|}{} & & \begin{tabular}[c]{@{}l@{}}El sistema de gestión de base de datos que se utiliza\ no permite procesar muchas transacciones por\ segundo como se esperaba.\end{tabular} & \ \cline{1-1} \cline{3-4} & & \begin{tabular}[c]{@{}l@{}}Falta de dominio en las tecnologías que se utilizan\ para la implementación del sistema\end{tabular} & \ \cline{3-4} & & & \ \cline{3-4} & & \begin{tabular}[c]{@{}l@{}}Las herramientas de desarrollo no se han elegido \ bien en función de las características técnicas y no\ proporcionan las prestaciones previstas\end{tabular} & \ \cline{2-4} \end{tabular} \end{table}

\end{document}

  • @gernot It helps me but it doesn't answer my question. – marcos vasquez Dec 23 '20 at 18:00
  • could you leave an example? – marcos vasquez Dec 23 '20 at 18:21
  • I have voted to reopen the question. It isn't completely straightforward to achieve what the OP wants, and the comments are just too restricted to communicate more elaborate examples. – gernot Dec 23 '20 at 19:46
  • Try \usepackage{array,multirow}\begin{document}\begin{tabular}{|c|p{2.5cm}|m{5cm}|c|}\hline R-01 & \multirow{4}={\centering Organizacion y gestion} & La estructura inadecuada de un quipo reduce la productividad. & probable \\ \cline{1-1}\cline{3-4} R-02 & & El plan de proyecto se abandona por la presion, llevando al caos, a un desarrollo ineficiente. & poco probable \\ \hline \end{tabular} \end{document} – gernot Dec 23 '20 at 19:48
  • I think that being a New contributor the question was closed to fast. If you want a table looking like the example: h-v lines, colors, vertically centered all rows, and fitting in \textwidth with normal font an a couple of multirows, the multirow are the least of your problems. An alternative is re issue the question saying: "This is exactly what I want, this is what I have done so far". You will be surprised how complex an innocent looking table might end. Please reopen the question. – Simon Dispa Dec 24 '20 at 00:04
  • Title of question is poor related with showed images. The same is valid for the provided MWE. It seems that OP is not aware for all issues of his table: coloring, multiline cells, vertical centering of cells' contents, vertical space around cells' contes. This is not addressed in linked question. – Zarko Dec 24 '20 at 03:17
  • vote to reopen? @Zarko – cfr Dec 24 '20 at 03:51
  • vote to reopen? @SimonDispa – cfr Dec 24 '20 at 03:51
  • vote to reopen? @gernot – cfr Dec 24 '20 at 03:51
  • @cfr, once I had already voted for open the question, but it was immediately closed again. I have prepared answer, the same I believe that Gernot too. So far no response from OP, if he agree that his question is duplicate. Frankly said, I don't know, what would be appropriate to do. – Zarko Dec 24 '20 at 04:09
  • @gernot I used the example you told me about but overleaf throws me the following error "Missing number, treated as zero" – marcos vasquez Dec 24 '20 at 04:23
  • I would like to t do it, but do not have enough reputation to vote, Or the OP can rephrase the question more properly. There are many questions of people wanted to reproduce a table from another source. – Simon Dispa Dec 24 '20 at 12:22

3 Answers3

1

One way to do so:

  • use type of cells, which enable automatic breaking of long text into multiline text. The candidates are p{<width>}, m{<column>}, X ... columns types
  • the \multirow in colored rows hade to be at and of colored rows and consequently had to have negative number of spanned rows
  • for coloring of table you need to load [table]{xcolor} package, in colored tables is advisable to use \hhline{...} instead of \hline and \cline{...}
  • for more space around column can serve cellspace package

Using tabularx environment for table, the MWE can be:

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\PassOptionsToPackage{es-tabla,spanish,es-lcroman,es-noquoting}{babel} %\usepackage{float} \usepackage{anysize}

\usepackage[table]{xcolor} \usepackage{ragged2e} \usepackage[column=O]{cellspace} \setlength\cellspacetoplimit{3pt} \setlength\cellspacebottomlimit{3pt} \usepackage{multirow, tabularx} \newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X} \addparagraphcolumntypes{L} \usepackage{hhline}

\begin{document}

\section{Introduction} \begin{table}[ht] \renewcommand\tabularxcolumn[1]{m{#1}} \renewcommand\multirowsetup{\centering} \setlength\tabcolsep{4pt} \begin{tabularx}{\linewidth}{|c|>{\Centering}m{7.7em}| OL| >{\Centering}m{7em}|} \hhline{|----|} \rowcolor{gray!30} \textbf{Id} & \textbf{Tipo de riesgo}
& \textbf{Riesgos}
& \textbf{Probabilidad} \ \hhline{|----|} R-01 & & & Probable \ \hhline{|-|~|--|} R-02 & \multirow{-2.4}{=}{some text}
& \cellcolor{cyan!30}{some text} & Poco probable \ \hhline{|----|} \rowcolor{gray!30} R-03 & & Las herramientas de desarrollo no funcionan como se esperaba & Probable \ \hhline{|-|>{\arrayrulecolor{gray!30}}->{\arrayrulecolor{black}}|--|} \rowcolor{gray!30} R-04 & & El sistema de gestión de base de datos que se utiliza\ no permite procesar muchas transacciones por\ segundo como se esperaba. & Probable \
\hhline{|-|>{\arrayrulecolor{gray!30}}->{\arrayrulecolor{black}}|--|} \rowcolor{gray!30} R-05 & & Falta de dominio en las tecnologías que se utilizan para la implementación del sistema & Probable \
\hhline{|-|>{\arrayrulecolor{gray!30}}->{\arrayrulecolor{black}}|--|} \rowcolor{gray!30} R-6 & & Debíl soporte sobre las tecnologías requeridas & Probable \ \hhline{|-|>{\arrayrulecolor{gray!30}}->{\arrayrulecolor{black}}|--|} \rowcolor{gray!30} R-7 & \multirow{-12}{=}{Entorno de desarrollo y tecnologías} & Las herramientas de desarrollo no se han elegido bien en función de las características técnicas y no proporcionan las prestaciones previstas & Probable \ \hline \end{tabularx} \end{table}

\end{document}

enter image description here

Zarko
  • 296,517
1

With the nicematrix package:

enter image description here

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\PassOptionsToPackage{es-tabla,spanish,es-lcroman,es-noquoting}{babel}

\usepackage{nicematrix}

\begin{document}

\section{Introduction} \begin{table}[ht] \centering \NiceMatrixOptions{cell-space-top-limit = 2pt,cell-space-bottom-limit = 2pt} \begin{NiceTabular}{c c m{8.5cm} c}[hvlines, code-before=\rowcolors{1}{gray!30}{}[respect-blocks] ] \textbf{Id} & \textbf{Tipo de riesgo}
& \textbf{Riesgos}
& \textbf{Probabilidad} \ R-01 & \Block{2-1}{some text} & & Probable \ R-02 &
& & Poco probable \ R-03 & \Block{5-1}{Entorno de\ desarrollo y\ tecnologías} & Las herramientas de desarrollo no funcionan como se esperaba & Probable \ R-04 & & El sistema de gestión de base de datos que se utiliza\ no permite procesar muchas transacciones por\ segundo como se esperaba. & Probable \
R-05 & & Falta de dominio en las tecnologías que se utilizan para la implementación del sistema & Probable \
R-6 & & Debíl soporte sobre las tecnologías requeridas & Probable \ R-7 &
& Las herramientas de desarrollo no se han elegido bien en función de las características técnicas y no proporcionan las prestaciones previstas & Probable \ \end{NiceTabular} \end{table}

\end{document}

leandriis
  • 62,593
  • +1 for nicematrix`, but it is pity that it need two compilations for final result. However, it eliminate pdfviewer artifacts ... – Zarko Dec 24 '20 at 15:38
1

As an alternative solution I used the nicematrix package that gives a simpler code. Only one package is needed to faithfully reproduce the example provided!

This is because it (for the most part) divides design from content, a good LaTeX premise. Only the definition of the two multiple rows is within the content of the table. (And the one cell Block for reasons I will explain later).

The vertical space inside the cells, the hv lines, the coloring of the cells can be modified without touching a single letter of the table itself. The five lines of the code (spaces, hv lines, colors) can be commented or edited to test alternative designs.

Important

I chose to split the long lines using linebreaks instead of letting LaTeX do it. It can be done without any additional packages, using one cell Block.

With a left-aligned paragraph, I like to cut the line where it makes grammatical sense and the flow of the sentence, instead or depending on the length of the next word. Each language has its own conventions for doing this.

\documentclass{article}

\PassOptionsToPackage{es-tabla,spanish}{babel}% not needed for this example but necessary in a spanish document

\usepackage{nicematrix}

\begin{document}

\section{Introducción}

\begin{table}[ht]

\NiceMatrixOptions{cell-space-top-limit = 7pt,cell-space-bottom-limit = 7pt}

\begin{NiceTabular}{cccc}[% hvlines, code-before = \rectanglecolor{blue!10}{3-3}{3-3}, code-before = \rectanglecolor{gray!15}{4-1}{8-4}, code-before = \rectanglecolor{gray!25}{1-1}{1-4}, ]
\bfseries ID & \bfseries Tipo de Riesgos &\bfseries Riesgos identificados &\bfseries Probabilidad \ R-01 & \Block{2-1}<\bfseries>{Organización \ y \ gestión} &\Block[l]{}{La estructura inadecuada de un equipo \ reduce la productividad} & Probable \ R-02 & & \Block[l]{}{El plan de proyecto se abandona por la presión, \ llevando al caos, un desarrollo ineficiente.} &Poco probable\ R-03 &\Block{5-1}<\bfseries>{Entorno de \ desarrollo \ y \ tecnologías} & \Block[l]{}{Las herramientas de desarrollo no funcionan \ como se esperaba}&Probable \ R-04 & & \Block[l]{}{El sistema de gestión de base de datos que se utiliza \ no permite procesar muchas transacciones por segundo,\ como se esperaba.}&Probable \ R-05 & &\Block[l]{}{Falta de dominio en las tecnologías que se utilizan \ para la implementación del sistema.} & {Probable} \ R-06 & & \Block[l]{}{Débil soporte sobre las tecnologías requeridas.} & Probable\ R-07 & & \Block[l]{}{Las herramientas de desarrollo no se han elegido bien, \ en función de las características técnicas, \ y no proporcionan las prestaciones previstas.} & Poco probable \ \end{NiceTabular}

\end{table}

\end{document}

nxx

Simon Dispa
  • 39,141
  • two answer with use nicematrix, :-). Yes, it need only one pacaked, but two compilation ;-). Also filling of cells at your solution is not so good as at other answers :-(. Anyway, +1 – Zarko Dec 24 '20 at 15:35
  • Thank you for the feedback !! :-) I prefer two compilations once in a while compared to what happens with a major LaTeX update and un-synchronized packages. Matter of opinion and previous experiences. I explained why to use linebreaks in narrow-left-align paragraphs leads to a better text flow for the reader, especially in tables and beamer. One extreme example of this is poetry. – Simon Dispa Dec 24 '20 at 16:55
  • oh, now i see, that have typing errors in my comment: pacaked should be package. In preparation of documents, I usually use testbed for prototyping of tables two compilation. There are two compilation that you can see table, serious limitation, especially when you finished table copied to (main) document start with development new table ...(as I usually do). To be honest, at least two compilation is also needed for long table(s) too (so far I didn't se nicematrix long table :-) – Zarko Dec 24 '20 at 17:06
  • In a large project I might have 40 or 50 tables developed during six or more months. Of course the style of the first table is different than the last. I had them in separated files, to input them into the main document.

    During the final reviews I collect all of them in a single collector document (only input) and made the changes in order to have a single uniform style, usually close to the last. Nice that the question was reopened.

    – Simon Dispa Dec 24 '20 at 17:42