0

I'm in trouble with the last column of my array. It's not vertically centered. I'd like to use as less package as possible, here my code and the result.

\usepackage{array}

%Some Text

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

%Some Text

\begin{tabular}{L{0.2\textwidth} C{0.2\textwidth} C{0.2\textwidth} C{0.2\textwidth}}
\rowcolor[HTML]{FFCB2F} 
\cellcolor[HTML]{FFCB2F}
\textbf{Pays}                       & \textbf{Volumes 2016} & \textbf{Part de marché (VP + VU)} & \textbf{Variation 2016 vs 2015 (en points)}\\[2em]
\rowcolor[HTML]{EFEFEF} 
France                              & 361 670               & 27,4 \%                           & + 0,5                                \\[1em]
Italie                              & 110 681               & 9,7 \%                            & + 0,5                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Allemagne                           & 97 671                & 5,2 \%                            & + 0,3                                \\[1em]
Espagne                             & 87 136                & 12,3 \%                           & - 0,7                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Turquie                             & 79 269                & 18,1 \%                           & + 2,4                                \\[1em]
Royaume-Uni                         & 71 967                & 4,4 \%                            & + 0,4                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Brésil                              & 69 874                & 7,3 \%                            & + 0,3                                \\[1em]
Inde                                & 61 895                & 3,8 \%                            & + 2,3                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Russie                              & 52 041                & 7,7 \%                            & + 0,4                                \\[1em]
Belgique + Luxembourg               & 51 466                & 13,5 \%                           & - 0,1                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Corée du sud                        & 46 917                & 7,1 \%                            & + 0,7                                \\[1em]
Aregntine                           & 39 491                & 12,2 \%                           & + 1,6                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Iran                                & 34 124                & 5,8 \%                            & + 4,6                                \\[1em]
Maroc                               & 31 034                & 37,0 \%                           & - 1,3                                \\[1em]
\rowcolor[HTML]{EFEFEF} 
Algérie                             & 29 132                & 41,7 \%                           & + 10,0                               \\[1em]
\end{tabular}

EDIT: Here is the result :

Result of the previous code

  • Can you complete your MWE please, so it compile once one copy past your code ie: add a complete code \documentclass{...} ... \begin{document}...\end{document} – SAM Jul 7 '16 at 10:36
  • I also suggest to use siunitx for the number alignment and % display – user31729 Jul 7 '16 at 11:19
2

This is due to the [2em]. I propose to change the value of arraystretch instead, and to improve the table & simplify its code with siunitx and makecell:

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage[table]{xcolor}
\usepackage{array, makecell, siunitx}
\renewcommand\theadfont{\bfseries\normalsize}
\definecolor{webgrey}{HTML}{EFEFEF}

\begin{document}

\sisetup{table-column-width=2.8cm, output-decimal-marker={,}}
\rowcolors{2}{}{webgrey}%
\renewcommand\arraystretch{1.6}
\begin{tabular}{l@{}S[table-format=6.0]S[table-format=2.1, table-space-text-post = {\,\%}]<{\,\%}S[table-format=+1.1]}% C{0.2\textwidth}
  \rowcolor[HTML]{FFCB2F}
  \cellcolor[HTML]{FFCB2F}
  \textbf{Pays}         & {\thead{Volumes 2016}} & \multicolumn{1}{c@{}}{\thead{Part de marché &        \\ (VP + VU)}}  & {\thead{Variation\\ 2016 vs 2015\\ (en points)}}\\
  France                & 361 670                & 27,4                                         & + 0,5  \\
  Italie                & 110 681                & 9,7                                          & + 0,5  \\
  Allemagne             & 97 671                 & 5,2                                          & + 0,3  \\
  Espagne               & 87 136                 & 12,3                                         & - 0,7  \\
  Turquie               & 79 269                 & 18,1                                         & + 2,4  \\
  Royaume-Uni           & 71 967                 & 4,4                                          & + 0,4  \\
  Brésil               & 69 874                 & 7,3                                          & + 0,3  \\
  Inde                  & 61 895                 & 3,8                                          & + 2,3  \\
  Russie                & 52 041                 & 7,7                                          & + 0,4  \\
  Belgique + Luxembourg & 51 466                 & 13,5                                         & - 0,1  \\
  Corée du sud         & 46 917                 & 7,1                                          & + 0,7  \\
  Argentine             & 39 491                 & 12,2                                         & + 1,6  \\
  Iran                  & 34 124                 & 5,8                                          & + 4,6  \\
  Maroc                 & 31 034                 & 37,0                                         & - 1,3  \\
  Algérie              & 29 132                 & 41,7                                         & + 10,0
\end{tabular}

\end{document} 

If you do not have access to all the packages, here is a simplified version, without the numbers alignment:

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[table]{xcolor}
\usepackage{array}
\definecolor{webgrey}{HTML}{EFEFEF}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}
\rowcolors{2}{}{webgrey}%
\renewcommand\arraystretch{1.6}
\begin{tabular}{l@{} C{2.8cm} C{2.8cm}<{\,\%} >{$}C{2.8cm}<{$}}%
  \rowcolor[HTML]{FFCB2F}
  \cellcolor[HTML]{FFCB2F}
  \textbf{Pays}         & \bfseries Volumes 2016 & \bfseries Part de marché \newline (VP + VU)  & \multicolumn{1}{C{2.8cm}}{\bfseries Variation\newline 2016 vs 2015\newline (en points)}\\
  France                & 361 670                & 27,4                                         & + 0,5  \\
  Italie                & 110 681                & 9,7                                          & + 0,5  \\
  Allemagne             & 97 671                 & 5,2                                          & + 0,3  \\
  Espagne               & 87 136                 & 12,3                                         & - 0,7  \\
  Turquie               & 79 269                 & 18,1                                         & + 2,4  \\
  Royaume-Uni           & 71 967                 & 4,4                                          & + 0,4  \\
  Brésil               & 69 874                 & 7,3                                          & + 0,3  \\
  Inde                  & 61 895                 & 3,8                                          & + 2,3  \\
  Russie                & 52 041                 & 7,7                                          & + 0,4  \\
  Belgique + Luxembourg & 51 466                 & 13,5                                         & - 0,1  \\
  Corée du sud         & 46 917                 & 7,1                                          & + 0,7  \\
  Argentine             & 39 491                 & 12,2                                         & + 1,6  \\
  Iran                  & 34 124                 & 5,8                                          & + 4,6  \\
  Maroc                 & 31 034                 & 37,0                                         & - 1,3  \\
  Algérie              & 29 132                 & 41,7                                         & + 10,0
\end{tabular}

\end{document} 

enter image description here

  • Which package are really necessary between those ? I have to manually install all of them because I have a VPN blocking not allowed connections. Edit: Because I don't understand your code – Biboozz Jul 7 '16 at 12:39
  • Normally all, but we can find work-arounds for makecell, for instance (it is used to have the \thead command at our disposal). Whicht are the packages which aren't installed? – Bernard Jul 7 '16 at 12:45
  • makecell, siunitx and lmodern – Biboozz Jul 7 '16 at 12:46
  • What??? Even lmodern, which is the recommended font for languages with accented letters? What's that VPN? – Bernard Jul 7 '16 at 12:52
  • I'm working on MikTeX portable in a Huge company (Renault) so they block connection from the outside for security reason – Biboozz Jul 7 '16 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.