I’m trying to limit my tables size and force line skip. Instead, the text reaches the end of the paper, at the same time I want it to have a grey background in one of the cells. I understand that the macro \makegapedcells in \makecell will remove this function. But what do i use instead?

enter image description here

And as you see i cant even get \makegapedcells to make the line shift now... But I’m sure there must be a better way?

\documentclass[a4paper, 11pt]{scrartcl}
\usepackage{comment} % enables the use of multi-line comments (\ifx \fi) 
\usepackage{fullpage} % changes the margin
\usepackage{fourier, erewhon}
\usepackage{array, makecell}


\author{Peter Molander}

\setcellgapes{1pt}%parameter for the spacing

%%%%%%%%%%%%% Add style 2 if u want diffrent headings %%%%%%%%%%%%%%%%%
Bilaga \textit{fumF{\yearnr}-{\FUM}.7}\\
\makebox[0.1\linewidth]{\rule{0.1\linewidth}{0.1pt}} \hspace{1cm} \makebox[0.1\linewidth]{\rule{0.1\linewidth}{0.1pt}} \hspace{1cm} \makebox[0.1\linewidth]{\rule{0.1\linewidth}{0.1pt}} \hspace{1cm} \makebox[0.1\linewidth]{\rule{0.1\linewidth}{0.1pt}} \hspace{1cm}\\}

%%%%%%%%%%% Change font size on section and sub section %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% And change the background color  %%%%%%%%%%%%%%%%%%%%%

    \setlength{\fboxsep}{0cm}%already boxed
            \vspace*{2pt}%Space before
            \vspace*{2pt}%Space after


%%%%%%%%%%%%%%%   Insert the FUM nr your on 1-8 + Year %%%%%%%%%%%%%%%%%

  /variables/#1.is family,
  /variables/#1.unknown/.style = {\pgfkeyscurrentpath/\pgfkeyscurrentname/.initial = ##1}



%%%%%%%%%%%%%%%      Pre-info        %%%%%%%%%%%%%%%%%%%%%%%%%
\textbf{\Large Fullmäktigesammanträde {\FUM}}\\\\
\textbf{Datum:} 20{\yearnr}-xx-xx\\
\textbf{Tid:} 17:15\\
\textbf{Plats:} Origo\\

%\textbf{Bilagor:}\\ Bilaga 1 - Dagordning\\ %Skall alltid bifogas som bilaga
%Bilaga 2 - Motioner, revisionberättelser etc\\ %Se stadgarna för aktuella bilagor

%%%%%%%%%%%%%%%      Formalia        %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Set Varible1 to the wanted sections start letter %%%%%%
 \setvalue{VARIABLE1 = F}

    & \color{white}{Formalia} 
    %& \color{white}{Anmärkningar}

%%%% .1 %%%%
\subsection*{\small \getvalue{VARIABLE1}{\yearnr}-{\FUM}.1}
        \small Mötets Öppnande 
        &  \colorbox{black!30}{\scriptsize long longlonglonglonglonglong}
%%%% .2 %%%%
\subsection*{\small \getvalue{VARIABLE1}{\yearnr}-{\FUM}.2} 
        \small Avstängning av mobiltelefoner 
        &  longlonglonglonglonglonglongllonglonglonglonglong

  • \cellcolor might be useful. Apart from that, could you please make your MWE a) more minimal and b) compilable?
    – leandriis
    Jun 11, 2019 at 14:31
  • tex.stackexchange.com/a/378630/134144 might also be interesting
    – leandriis
    Jun 11, 2019 at 14:40
  • Yeah i saw that link before but i cant get that to work properly the way i want it. See the background color extends over the entire row and not a single cell? About the MWE i can compile with one error that i cant remove also if i try to make it more minimal it just filps and gets a lot of error for everything... Kinda new to this Jun 12, 2019 at 9:47

1 Answer 1


I guess that the problem is the narrow p-column and the long word. The p-column is only 15mm, so it does not allow for long word. Also, LaTeX does not hyphenate the first word in a cell without a little trick. In addition, the longlong word is artificial and does not contain places where LaTeX may hyphenate (it is not a Swedish word). Place some strategic \- or spaces in the word, and see the result.

%%%% .1 %%%%
\subsection*{\small \getvalue{VARIABLE1}{\yearnr}-{\FUM}.1}
    \begin{tabular}[t]{l|p{25mm}} % If you are allowed
        \small Mötets Öppnande 
        &  \cellcolor{lightgray} \scriptsize \hspace{0pt}short text only
%%%% .2 %%%%
\subsection*{\small \getvalue{VARIABLE1}{\yearnr}-{\FUM}.2} 
        \small Avstängning av mobiltelefoner 
        &  \cellcolor{lightgray} \scriptsize \hspace{0pt}only short text allowed

It is obviously not meant for storing long text. Try to put in ordinary text with space between, so LaTeX is able to hyphenate it. If you are allowed, increase the width to for example 25 mm. Also, start the first word with \hspace{0pt} so the first word will be hyphenated.

I have not tested this code, because your code did not compile (I got approximately 100 error messages).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .