0

I want to recreate this table

The 5th row is killing me. How can i determine the width of the rows? I manage to scrap up the code underneath.

\begin{table}[h]
    \centering
    \begin{tabular}{|p{11.2cm}|p{3cm}|}
    \hline
       \textbf{Fag:}   & \textbf{Dato:} 17.01.20 \\
    \hline
        \multicolumn{2}{|l|}{\textbf{Prosjekt:}} \\
    \hline
        \textbf{Aktivitet:} & \textbf{Aktivitet nr: } \\
    \hline
        \multicolumn{2}{|l|}{\begin{tabular}[t]{p{7cm}|p{7cm}}
         \textbf{Startdato:}  & \textbf{Sluttdato: }
        \end{tabular}} \\ 
    \hline
    \end{tabular}
\end{table}
  • Welcome to TeX SX! What do you want to achieve, exactly? – Bernard Jan 17 at 16:01
2

Don't try to determine the widths manually, latex will do it

\documentclass{article}
\usepackage{geometry}

\usepackage{multirow,tabularx}

\begin{document}

\begin{table}[h]
\centering
\begin{tabularx}{\linewidth}{|X|X|X|X|X|X|}
\hline
\multicolumn{5}{|>{\hsize=\dimexpr5\hsize+4\tabcolsep+\arrayrulewidth\relax}X|}{\textbf{Fag:}}   & \textbf{Dato:} 17.01.20 \\
\hline
\multicolumn{6}{|X|}{\textbf{Prosjekt:}} \\
\hline
\multicolumn{5}{|X|}{\textbf{Aktivitet:}} & \textbf{Aktivitet nr: } \\
\hline
\multicolumn{3}{|>{\hsize=\dimexpr3\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{\textbf{Startdato:}}  & \multicolumn{3}{|X|}{\textbf{Sluttdato:}}\\
\hline
\multirow{2}{*}{\textbf{Avhengighey:}} & \multicolumn{5}{|>{\hsize=\dimexpr5\hsize+4\tabcolsep+\arrayrulewidth\relax}X|}{\textbf{Foregaende aktiviteter:}}\\
\cline{2-6}
 & \multicolumn{5}{|X|}{\textbf{Etterfolende aktiviteter:}}\\
\hline
\end{tabularx}
\end{table}

\end{document}
  • Probably you might want to use \multicolumn{3}{|>{\hsize=\dimexpr3\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{\textbf{Startdato:}} & \multicolumn{3}{X|}{\textbf{Sluttdato:}}\\ \hline \multirow{2}{*}{\textbf{Avhengighey:}} & \multicolumn{5}{>{\hsize=\dimexpr5\hsize+4\tabcolsep+\arrayrulewidth\relax}X|}{\textbf{Foregaende aktiviteter:}}\\ \cline{2-6} & \multicolumn{5}{>{\hsize=\dimexpr5\hsize+4\tabcolsep+\arrayrulewidth\relax}X|}{\textbf{Etterfolende aktiviteter:}}\\ \hline. – leandriis Jan 17 at 16:23
  • This removes the double vertical line in row 4 and row 5-6 and will also remove the linebreak of the entry in the last row. However, please note that thie will still roduce an overfull box warning since "Avhengighey:" is too wide for an X column. To also prevent this, you could go for something like \begin{tabularx}{\linewidth}{|l|X|X|X|X|l|}. – leandriis Jan 17 at 16:23
  • Thanks, it helped a lot! – user205093 Jan 17 at 16:25

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.