2

There are already many answers to this question, but no one seems to have the solution for my case. My table looks, written with the following code, like this:

\documentclass[a4paper,9pt]{extarticle}
\usepackage[a4paper,left=2.4cm,right=1.4cm,top=1.4cm,bottom=1.4cm,footskip=0cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{xcolor}
  \definecolor{row_even}{cmyk}{0, 0, 0, 0.12} % define color
  \definecolor{row_uneven}{cmyk}{0, 0, 0, 0.24} % define color
\usepackage{helvet} % Helvetica font
  \renewcommand{\familydefault}{\sfdefault}
\usepackage{fancyhdr} % page numbering
\renewcommand{\headrulewidth}{0pt} % remove top line
\usepackage{colortbl}
\usepackage{float} % define table lines
  \makeatletter
  \newcommand{\thickhline}{\noalign {\hrule height 2pt}}
  \newcolumntype{'}{!{\color{white}\vrule width 2pt}}
  \newcolumntype{+}{!{\vrule width 0.2em}}
  \makeatother
\usepackage{tabularx}
  \newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\arraybackslash}X}%
  \newcolumntype{R}[1]{>{\hsize=#1\hsize\raggedleft\arraybackslash}X}%
  \newcolumntype{C}[2]{>{\hsize=#1\hsize\columncolor{#2}\centering\arraybackslash}X}
  \newcolumntype{S}{>{\hsize=0pt}X}
\usepackage{array}
\usepackage{ctable} % different line thickness
\usepackage{multirow} % cell over multiple rows in table

\begin{document}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}
\begin{center}
\rowcolors{1}{row_uneven}{row_even}
  \begin{tabularx}{\textwidth}{ + L{0.7} ' C{0.15}{row_uneven} ' C{0.15}{row_uneven} + }
  \specialrule{.05em}{1em}{0em} 
  Swahili & yes & no \\[0.3cm]
  Swedish &  &  \\[0.3cm]
  Dutch &  &  \\[0.3cm]
  English &  &  \\[0.3cm]
  German  &  &  \\[0.3cm]
  \specialrule{.2em}{.0em}{.0em}
  \multicolumn{3}{+ l +}{\textbf{further languages:}} \\[0.8cm]
  \specialrule{.2em}{.0em}{.0em}
  \end{tabularx}
\end{center}
\end{document}

enter image description here

You can see how the first two columns are vertically centred, but not the third one. Also the text within \multicolumn command isn't centred. I know that I could tackle to problem with the 3rd column by just using a 4th column with zero width. But I have tried that unsuccessfully because the rows are coloured. Could I maybe define my own column type, so that I have to use \begin{tabularx}{\linewidth}{ + X ' X ' X + }? But how would I do that?

1 Answer 1

1

This is a bug if m column type is used in the last column. A workaround will be to use another dummy column as the last column like

@{\kern-\tabcolsep}L{0}@{\kern2\tabcolsep} +

in

\begin{tabularx}{\textwidth}{ + L{0.7} ' C{0.15}{row_uneven} ' C{0.15}
                        {row_uneven}@{\kern-\tabcolsep}L{0}@{\kern2\tabcolsep} + }

You have to add an extra & in all the rows.

\documentclass[a4paper,9pt]{extarticle}
\usepackage[a4paper,left=2.4cm,right=1.4cm,top=1.4cm,bottom=1.4cm,footskip=0cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{xcolor}
  \definecolor{row_even}{cmyk}{0, 0, 0, 0.12} % define color
  \definecolor{row_uneven}{cmyk}{0, 0, 0, 0.24} % define color
\usepackage{helvet} % Helvetica font
  \renewcommand{\familydefault}{\sfdefault}
\usepackage{fancyhdr} % page numbering
\renewcommand{\headrulewidth}{0pt} % remove top line
\usepackage{colortbl}
\usepackage{float} % define table lines
  \makeatletter
  \newcommand{\thickhline}{\noalign {\hrule height 2pt}}
  \newcolumntype{'}{!{\color{white}\vrule width 2pt}}
  \newcolumntype{+}{!{\vrule width 0.2em}}
  \makeatother
\usepackage{tabularx}
  \newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\arraybackslash}X}%
  \newcolumntype{R}[1]{>{\hsize=#1\hsize\raggedleft\arraybackslash}X}%
  \newcolumntype{C}[2]{>{\hsize=#1\hsize\columncolor{#2}\centering\arraybackslash}X}
  \newcolumntype{S}{>{\hsize=0pt}X}
\usepackage{array}
\usepackage{ctable} % different line thickness
\usepackage{multirow} % cell over multiple rows in table

\begin{document}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}
\begin{center}
\rowcolors{1}{row_uneven}{row_even}
  \begin{tabularx}{\textwidth}{ + L{0.7} ' C{0.15}{row_uneven} ' C{0.15}{row_uneven}@{\kern-\tabcolsep}L{0}@{\kern2\tabcolsep} + }
  \specialrule{.05em}{1em}{0em}
  Swahili & yes & no &  \\[0.3cm]
  Swedish &  & & \\[0.3cm]
  Dutch &  & & \\[0.3cm]
  English &  & & \\[0.3cm]
  German  &  & & \\[0.3cm]
  \specialrule{.2em}{.0em}{.0em}
  \multicolumn{4}{+ l +}{\textbf{further languages:}} \\[0.8cm]
  \specialrule{.2em}{.0em}{.0em}
  \end{tabularx}
\end{center}
\end{document}

enter image description here

4
  • thanks! do you also know a trick on how I could also vertically align the 'further languages' row?
    – Christovis
    Commented Sep 15, 2015 at 10:54
  • @Hiro With l column type and \multicolumn things get nasty. Use some thing like \raisebox{-0.4cm}{\textbf{further languages:}}. -0.4cm is half of 0.8cm.
    – user11232
    Commented Sep 15, 2015 at 11:00
  • Hi Harish, thanks for you help! I will try my luck with another question: Do you maybe know why if I type Swahili & yes & no & \\[0.3cm] the row isn't 0.3cm high but more like 0.5cm? Do you know how I can delete this extra space?
    – Christovis
    Commented Sep 15, 2015 at 15:38
  • @Hiro Try with ` \\ \noalign{\vspace{0.3cm}}`
    – user11232
    Commented Sep 15, 2015 at 15:39

You must log in to answer this question.

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