[Tex/LaTex] How to add vertical line in table between a multicolumn and a column

linemulticolumntablesvertical

I hope you can help me out as I've been struggling with this for quite a while.

I'm trying to add a vertical line before and after the multicolumn holding "Capacity [MW]" so the two lines (before "Spain" and after "Portugal") continues to the top – please see picture.

Table

My code is here. Please note, that I use the \usepackage{makecell}.

\begin{table}[htbp]
\caption{Assumed transmission capacity for the Balmorel model.}
\centering
\begin{tabular}{l|c|c|c|c}
\hline
\multicolumn{2}{c}{}            &\multicolumn{2}{c}{\thead{\textbf{Capacity [MW]}}} &\textbf{}\\
\hline
\textbf{Technology type}                &\textbf{Fuel}      &\textbf{Spain}       &\textbf{Portugal}                &\textbf{Efficiency}\\
\hline
 PT $\rightarrow$ ES                    & 2954              & 3500              & 3500                          &5\% \\
 ES $\rightarrow$ PT                    & 2085              & 4200              & 4200                          &5\% \\
\hline 
 FR $\rightarrow$ ES                    & 450               & 2800              & 8000                          &5\% \\ 
 ES $\rightarrow$ FR                    & 325               & 2500              & 8000                          &5\% \\
\hline
\end{tabular}
\label{tab:transcap}
\end{table}

Thanks in advance!

Best Answer

You can add a | to multicolumn commands (\multicolumn{2}{c|}) like this

\documentclass{article} 
\usepackage{makecell}

\begin{document}
\begin{table}[htbp]
\caption{Assumed transmission capacity for the Balmorel model.}
\centering
\begin{tabular}{l|c|c|c|c}
\hline
\multicolumn{2}{c|}{}            &\multicolumn{2}{c|}{\thead{\textbf{Capacity [MW]}}} &\textbf{}\\
\hline
\textbf{Technology type}                &\textbf{Fuel}      &\textbf{Spain}       &\textbf{Portugal}                &\textbf{Efficiency}\\
\hline
 PT $\rightarrow$ ES                    & 2954              & 3500              & 3500                          &5\% \\
 ES $\rightarrow$ PT                    & 2085              & 4200              & 4200                          &5\% \\
\hline 
 FR $\rightarrow$ ES                    & 450               & 2800              & 8000                          &5\% \\ 
 ES $\rightarrow$ FR                    & 325               & 2500              & 8000                          &5\% \\
\hline
\end{tabular}
\label{tab:transcap}
\end{table}
\end{document}

In other combinations (e.g. \multicolumn{2}{|c|} in central columns) vertical lines seem to be not well aligned.