第 5 行让我头疼。我该如何确定行宽?我设法整理了下面的代码。
\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}
答案1
不要尝试手动确定宽度,Latex 会帮你搞定
\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}