1

I have used colour to mark some cells in a table, but the final cell (right, bottom) seems to "overflow".

\documentclass[nols,notitlepage,openany,12pt,table,xcdraw]{tufte-handout}

\usepackage{geometry}
\geometry{a4paper,bottom=1.5in}

\usepackage{fontspec}
\setmainfont[Mapping=tex-text,Numbers=OldStyle]{Minion Pro}
\setsansfont[Mapping=tex-text,Numbers=OldStyle]{Gill Sans}

\usepackage{booktabs}

\usepackage{enumitem}
% \setlist{nolistsep} % or \setlist{noitemsep} to leave space around whole list
\setlist{noitemsep}
\usepackage{adjustbox}
\begin{document}


\begin{table}[h!]
\begin{tabular}{@{}lllll@{}}

2020 & 2021 & 2022                                           & 2023-25                                & 2025-2030                                     \\ \midrule
\multicolumn{5}{l}{\cellcolor[HTML]{EFEFEF}Individuella ansökningar}                                                                                  \\
     & \multicolumn{4}{l}{\cellcolor[HTML]{EFEFEF}Gemensamma ansökningar}                                                                             \\
     &      & \cellcolor[HTML]{EFEFEF}Strategisk publicering & \cellcolor[HTML]{EFEFEF}Programansökan &                                               \\
     &      &                                                &                                        & \cellcolor[HTML]{EFEFEF}Lansering av institut
\end{tabular}
\end{table}

\end{document}

Output:

problematic overflow in final cell of table

It does not solve itself by writing less in the final cell.

trmdttr
  • 857
  • it's the @{} use \multicolumn{1}{>{\columncolor[HTML]{EFEFEF}}{l@{}} instead of \cellcolor – David Carlisle Sep 24 '19 at 13:59
  • Aha, I got the code from https://tablesgenerator.com/ – trmdttr Sep 24 '19 at 14:07
  • Sorry, @DavidCarlisle, I can't seem to fix it – should I change something on the two last rows as well? It doesn't seem to work if I only change the multicolumn rows. Maybe there is another better approach I should use. – trmdttr Sep 24 '19 at 14:12

1 Answers1

1

Use <{\kern-\tabcolsep}, also necessary in the multicolumns, and add \\ to the last row. I you have p/m/b-columns, you have to take special steps, see this question and its answers:

enter image description here

\documentclass[12pt,table,xcdraw]{article}
\usepackage{geometry}
\geometry{a4paper,bottom=1.5in}
\usepackage{booktabs, xcolor}

\begin{document}

\begin{table}
\begin{tabular}{>{\kern-\tabcolsep}lllll<{\kern-\tabcolsep}}

2020 & 2021 & 2022                                           & 2023-25                                & 2025-2030                                     \\ \midrule
\multicolumn{5}{>{\kern-\tabcolsep}l<{\kern-\tabcolsep}}{\cellcolor[HTML]{EFEFEF}Individuella ansökningar}                                                                                  \\
     & \multicolumn{4}{l<{\kern-\tabcolsep}}{\cellcolor[HTML]{EFEFEF}Gemensamma ansökningar}                                                                             \\
     &      & \cellcolor[HTML]{EFEFEF}Strategisk publicering & \cellcolor[HTML]{EFEFEF}Programansökan &                                               \\
     &      &                                                &                                        & \cellcolor[HTML]{EFEFEF}Lansering av institut\\
\end{tabular}
\end{table}
\end{document}
Sveinung
  • 20,355