Overleaf 中的表格格式问题

Overleaf 中的表格格式问题

我正在使用 Overleaf 制作报告,但我的表格标题格式不正确。这是代码的初始部分(表格很长,跨越两页 - 它有 20 行。

我完全是个初学者,所以搞不清楚这里出了什么问题。最后两列的红色没有正确反映出来。请帮忙!这是一个小问题,但很烦人。 在此处输入图片描述

\begin{center}
\label{table:2}

\begin{longtable}{ | m{1.5cm} | m{2cm} | c | c | c | c  | c | c | }

\multicolumn{8}{|r|}{{Continued on next page}} \\
\endfoot

\hline \hline
\endlastfoot

\caption{Status and national electrification plans and achievements in five selected African countries (Source: MEI)}

  \hline \hline
  \rowcolor{redmei} \color{white}
  Country & \color{white} Electrification Plans & \color{white} \thead{Total Offgrid \\ Population \\ (million)} & \color{white} \thead{Electrification \\ Rate} & \color{white} \thead{Rural \\ Electrification \\ Rate} & \color{white} \thead{Urban \\ Electrification \\ Rate} & \color{white} \thead{Power \\ Outages \\ (duration \\-hours)} & \color{white} \thead{Power \\ Outages \\ (frequency\\-month)}  \\ 
  \hline
    \cellcolor{redmei} \color{white} 
    Uganda & 26\% coverage by 2022; 51\% coverage by 2030 & 32.1 & 22\% & 10\% & 55\% & 6 & 6.3 \\
  \hline
    \cellcolor{redmei} \color{white} 
    Kenya& 65\% coverage by 2022; universal by 2030& 35.4 & 20\% & 7\% & 60\% & 6 & 6.3 \\
  \hline    
    \cellcolor{redmei} \color{white} 
    Rwanda & 70\% of HH connected by 2018, 100\% by 2020 & 9.3  & 21\%  & 5\%   & 67\% & 4 & 4 \\
.
.
.
.
   \hline

\end{longtable}
\end{center}

答案1

如果我纠正评论中已经提到的错误,我就无法重现您的问题:

在此处输入图片描述

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage{makecell}
\definecolor{redmei}{RGB}{192,0,0}
\begin{document}

%

\begin{longtable}{ | l | >{\raggedright\arraybackslash}m{2.2cm} | c | c | c | c  | c | c | }

\multicolumn{8}{|r|}{{Continued on next page}} \\
\endfoot

\hline \hline
\endlastfoot

\caption{Status and national electrification plans and achievements in five selected African countries (Source: MEI)}\label{table:2}\\

  \hline \hline
  \rowcolor{redmei} \textcolor{white}{Country} & \textcolor{white}{ Electrification Plans} & \textcolor{white}{ \thead{Total Offgrid \\ Population \\ (million)}} & \textcolor{white}{ \thead{Electrification \\ Rate}} & \textcolor{white}{ \thead{Rural \\ Electrification \\ Rate}} & \textcolor{white}{ \thead{Urban \\ Electrification \\ Rate}} & \textcolor{white}{ \thead{Power \\ Outages \\ (duration \\-hours)}} & \textcolor{white}{ \thead{Power \\ Outages \\ (frequency\\-month)}}  \\ 
  \hline
    \cellcolor{redmei} \textcolor{white}{Uganda} & 26\% coverage by 2022; 51\% coverage by 2030 & 32.1 & 22\% & 10\% & 55\% & 6 & 6.3 \\
  \hline
    \cellcolor{redmei} \textcolor{white}{Kenya} & 65\% coverage by 2022; universal by 2030& 35.4 & 20\% & 7\% & 60\% & 6 & 6.3 \\
  \hline    
    \cellcolor{redmei} \textcolor{white}{Rwanda} & 70\% of HH connected by 2018, 100\% by 2020 & 9.3  & 21\%  & 5\%   & 67\% & 4 & 4 \\

   \hline

\end{longtable}

\end{document}

相关内容