1

this is my file:

\documentclass[a4paper]{article}
\usepackage{multirow, tabularx}

\begin{document}
    \begin{table}[!ht]
        \renewcommand\arraystretch{1.5}
        \newcommand\mcl[1]{\multicolumn{3}{l|}{#1}}
        \caption{Tabella di Cockburn}

        \begin{tabularx}{\linewidth}{|l|>{\hsize=0.4\hsize}X|
                >{\hsize=1.8\hsize}X|
                >{\hsize=0.8\hsize}X|}
            \hline 
            Use Case \#N    & \mcl{Login}                               \\ 
            \hline
            Goal in Context & \mcl{Per identificarsi}                   \\
            \hline 
            Preconditions   & \mcl{L'utente deve avere già un account}  \\
            \hline 
            Success End Conditions 
            & \mcl{L'utente è stato identificato nel sistema}       \\
            \hline 
            Failed End Conditions 
            &   \multicolumn{3}{>{\hsize=\dimexpr3\hsize+6\tabcolsep+3\arrayrulewidth}X|}{ 
                Lorem ipsum dolor sit amet, consectetur adipiscing elit.} \\
            \hline 
            Primary Actor   & \mcl{Attore principale dello UC}                      \\
            \hline 
            Trigger         & \mcl{Azione principale dell'attore che attiva lo UC}  \\
            \hline 
            Description     & Step  & User Action               & System            \\  \cline{2-4} 
            & 1     & L'utente clicca OK        &                   \\  \cline{2-4} 
            & 2     &                           & Mostra M1         \\  \cline{2-4} 
            & 3     & L'utente clicca Cliccami  &                   \\  \cline{2-4} 
            & 4     &                           & Chiude            \\
            \hline 
            Extensions      & Step  & User Action               & System            \\  \cline{2-4} 
            &   &   &   \\
            \hline
            Subvariations   & Step  & User Action               & System            \\  \cline{2-4} 
            &   &   &   \\
            \hline 
            Notes           &   &   &   \\
            \hline
        \end{tabularx}
    \end{table}
\end{document}

which leads to this

enter image description here

  • How can I edit the file so that on User Action's right there is another column which can be filled such as for User Action? As the following image shows:

enter image description here

4
  • 2
    Quite simple :-) (i) add one more column specifier to table specification , (ii) accordingly redetermine \multicolum -- it now span four columns, six \tabcol spaces and three arrayrulewidth ... It seems that you also need to define columns with again (from scratch). I will write answer latter when will have more spare time. if this will still needed.
    – Zarko
    Commented Mar 19, 2020 at 16:49
  • sorry i'm newbie with latex and i still can't solve my problem even with your hint... :(
    – ItsGhost
    Commented Mar 19, 2020 at 16:52
  • I will write answer late evening (GMT), be patient.
    – Zarko
    Commented Mar 19, 2020 at 17:17
  • I succeed to find enough spare time for converting my comment to an answer. See if it fulfill your expectation.
    – Zarko
    Commented Mar 19, 2020 at 21:08

2 Answers 2

1

Let me change my comment into answer. In MWE below are all changes in comparison to the your MWE explained by comments in code.

\documentclass[a4paper]{article}
\usepackage{makecell, tabularx}
\renewcommand\theadfont{\small\bfseries} % for headers in "description" row
\renewcommand\theadgape{}                % removed aditional vertical space around \thead   
\newlength{\pwidth}

\usepackage{lipsum} % for generating dummy test
\begin{document}
    \begin{table}[!ht]
\setcellgapes{2pt}
\makegapedcells                     % for additional vertical space in cells
\setlength\tabcolsep{4pt}           % reduce \tabcolspace from default value 6pt, 
                                    % with this cell content has 4pt more space
\settowidth\pwidth{Preconditions}   % as suggested in my answer 
                                    % on one of your previous question
% shortcut \newcommand\mcl[1]{\multicolumn{3}{l|}{#1}} is desingned
% for spanning three column, but with increasing number of columns
% it should now span four columns:
\newcommand\mcl[1]{\multicolumn{4}{l|}{#1}}
    \caption{Tabella di Cockburn}
    \label{tab:cockburn}    % for referencing this table
\begin{tabularx}{\linewidth}{|>{\raggedright}p{\pwidth}|
% Here is inserted additional column. From provided image has the same width
% as last two column. In definig columns width we bear in mind, that sum of 
% X column had to be integer number equal to number of X columns in table:
        >{\hsize=0.55\hsize}X|
        >{\hsize=1.15\hsize}X|
        >{\hsize=1.15\hsize}X|
        >{\hsize=1.15\hsize}X|}
            \hline
%        1   &   2   &   3   &   4   &   5                   \\
Use Case \#N    & \mcl{Login}                               \\
    \hline
Goal in Context & \mcl{Per identificarsi}                   \\
    \hline
Preconditions   & \mcl{L'utente deve avere già un account}  \\
    \hline
Success End Conditions
                & \mcl{L'utente è stato identificato nel sistema}       \\
    \hline
Failed End Conditions
                &   \multicolumn{4}% % cell now span 4 columns, 6 \tabcolsep, 3 \arrayrulewidth 
                                {>{\hsize=\dimexpr4\hsize+6\tabcolsep+3\arrayrulewidth}X|}%
                                {\lipsum[11]} \\
    \hline
Primary Actor   & \mcl{Attore principale dello UC}                      \\
    \hline
Trigger         & \mcl{Azione principale dell'attore che attiva lo UC}  \\
    \hline
Description     &  \thead{Step $n$} 
                        & \thead{Attore 1} 
                                & \thead{Attore $n$} 
                                        & \thead{SIstema}               \\  \cline{2-5}
                & 1     & Azzione trigger   
                                &       &                               \\  \cline{2-5}
                & 2     &       &       & Mostra M1                     \\  \cline{2-5}
                & \dots & Azione 2          
                                &       &                               \\  \cline{2-5}
                & $n$   &       &       & Chiude                        \\
    \hline
\end{tabularx}
    \end{table}
\end{document}

enter image description here

0

This should work for you

\documentclass[a4paper]{article}
\usepackage{multirow, tabularx}

\begin{document}
    \begin{table}[!ht]
        \renewcommand\arraystretch{1.5}
        \newcommand\mcl[1]{\multicolumn{4}{l|}{#1}}
        \caption{Tabella di Cockburn}

        \begin{tabularx}{\linewidth}
            {
                |l|>{\hsize=0.4\hsize}X|
                >{\hsize=1.8\hsize}X|
                >{\hsize=0.8\hsize}X|
                >{\hsize=0.8\hsize}X|
            }
            \hline
            Use Case \#N    & \mcl{Login}                               \\
            \hline
            Goal in Context & \mcl{Per identificarsi}                   \\
            \hline
            Preconditions   & \mcl{L'utente deve avere già un account}  \\
            \hline
            Success End Conditions
            & \mcl{L'utente è stato identificato nel sistema}       \\
            \hline
            Failed End Conditions
            &   \multicolumn{4}{>{\hsize=\dimexpr3\hsize+6\tabcolsep+3\arrayrulewidth}X|}{
                Lorem ipsum dolor sit amet, consectetur adipiscing elit.} \\
            \hline
            Primary Actor   & \mcl{Attore principale dello UC}                      \\
            \hline
            Trigger         & \mcl{Azione principale dell'attore che attiva lo UC}  \\
            \hline
            Description     & Step  & Attore 1 & attore n               & sistema            \\  \cline{2-5}
            & 1     & L'utente clicca OK        &                   & \\  \cline{2-5}
            & 2     &                           & Mostra M1         & \\  \cline{2-5}
            & 3     & L'utente clicca Cliccami  &                   & \\  \cline{2-5}
            & 4     &                           & Chiude            & \\
            \hline
            Extensions      & Step  & User Action               & System            & \\  \cline{2-5}
            &   &   &   & \\
            \hline
            Subvariations   & Step  & User Action               & System            & \\  \cline{2-5}
            &   &   &   & \\
            \hline
            Notes           &   &   &   & \\
            \hline
        \end{tabularx}
    \end{table}
\end{document}

The thing is that you have a \mcl command defined at line 7 that is meant as a shortcut for the \multicolumn one. There's nothing wrong with thay. However, later in the table, \multicolumn is used explicitely. Therefore, you should have changed the multicolumn column argument from 3 to 4 twice. And probably the problem was here.

\multicolumn is not an extremely long command, and, if you are new to LaTeX, try to use the native commands of the package, before defining (ur usign already defined) shortcuts. Most editors provide easy "find and replace" functions that will save you time. When you feel confident enough, use command shortcuts at your will ;)

And this is my personal interpretation of the table you required, with dome additional embellishment and something less (the table is not that complex that you need to force the width of the column with \hsize, you just need to know which columns need to stretch X, and which not, like the second and maybe the fourth)

\documentclass[a4paper]{article}
\usepackage{multirow, tabularx}

\usepackage{booktabs}

\begin{document}
    \begin{table}[tb]
        \renewcommand\arraystretch{1.5}
        \newcommand\mcl[1]{\multicolumn{4}{l}{#1}}
        \centering
        \caption{Tabella di Cockburn}
        \label{tab:tabella-cockburn}
        \begin{tabularx}{\textwidth}{llXXl}
            \toprule
            \textbf{Use Case \#N}  & \mcl{\textbf{Login}}                                   \\ \toprule
            Goal in Context        & \mcl{Per identificarsi}                                \\ \midrule
            Preconditions          & \mcl{L'utente deve avere già un account}               \\ \midrule
            Success End Conditions & \mcl{L'utente è stato identificato nel sistema}        \\ \midrule
            Failed End Conditions  & \mcl{lorem ipsum dolor sit amet}                       \\ \midrule
            Primary Actor          & \mcl{Attore principale dello UC}                       \\ \midrule
            Trigger                & \mcl{Azione principale dell'attore che attiva lo UC}   \\ \midrule
            \textsc{Description}   & \textbf{Step} & \textbf{Attore 1}        & \textbf{Attore $n$} & \textbf{Sistema} \\ \cline{2-5}
                                   & 1             & L'utente clicca OK       &                     & \\ \cline{2-5}
                                   & 2             &                          & Mostra M1           & \\ \cline{2-5}
                                   & 3             & L'utente clicca Cliccami &                     & \\ \cline{2-5}
                                   & 4             &                          & Chiude              & \\ \midrule
            \textsc{Extensions}    & \textbf{Step} & \textbf{Attore 1}        & \textbf{Attore $n$} & \textbf{Sistema} \\ \cline{2-5}
                                   &               &                          &                     & \\ \midrule
            \textsc{Subvariations} & \textbf{Step} & \textbf{Attore 1}        & \textbf{Attore $n$} & \textbf{Sistema} \\ \cline{2-5}
                                   &               &                          &                     & \\ \midrule
            \textsc{Notes}         & \mcl{one note spanning 4 columns} \\
                                   & note 1        & note 2                   & note 3              & note 4 \\
            \bottomrule
        \end{tabularx}
    \end{table}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .