0

can you please help me with this table. I tried many times to center vertically the last column but it doesn't work and even the space it's not good at all. I used the X (tabularx) but it seems not really managed by latex.If you have other teps To make my table look even good I will appreciated. thank you so much :) ps: it's for a phd thesis

\documentclass[oneside,a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{libertine}
   \usepackage{amsmath}
  \usepackage{amssymb}
\usepackage{emptypage} %prevents page numbers and heading appearing in empty pages
 \usepackage[french]{babel}
    \usepackage[top=3cm,bottom=2.5cm,left=2.5cm,right=2.5cm,headheight=26pt,headsep=25pt,heightrounded]{geometry}
 \frenchbsetup{FrenchFootnotes=false}  %more common footnote style
 \usepackage[hang,flushmargin]{footmisc} % footnote presentation
 \usepackage{enumerate}          % personnaliser les listes
   \usepackage[babel,french=guillemets]{csquotes}           
 \usepackage{graphicx}
  \setcounter{tocdepth}{5}     % level of sectionnin titles printed in TOC
  \setcounter{secnumdepth}{5} %sectionning titles are numbered: level 5
  \usepackage[titles]{tocloft} % nom du chapitre apparait en TOC
  \graphicspath{{\images}}
   \usepackage[dvipsnames,table]{xcolor}
  \usepackage{array,booktabs} 
  \usepackage{xfrac}
   \usepackage{refcount}
   \usepackage{tikz}
  \usetikzlibrary{backgrounds}
  \usepackage{tikzpagenodes}
  \usepackage{xspace}
   \usepackage{setspace}  %interligne 1.5
    \usepackage[parfill]{parskip}  % espace entre deux paragraphes
     \usepackage{calc}
     \usepackage[explicit]{titlesec}
     \usepackage{shorttoc}
      \usepackage{enumitem} % modifier et personaliser les puces des listes
       \usepackage{pifont} % les symboles pour les listes
      \usepackage[french]{minitoc}
     \usepackage{etoolbox}
     \usepackage{sectsty}
    \allsectionsfont{\raggedright}
       \AtBeginEnvironment{footcitedquote}{\singlespacing\small}
       \AtBeginEnvironment{fancyquotes}{\small}
        %\setlength{\parskip}{10pt plus 1pt minus 1pt}}
      \setlength{\overfullrule}{5pt} % show the hfull and underfull vbox hbox warning

        \usepackage{smartdiagram}
          \usepackage{tabularx}
           \usepackage{multirow}

    % define colors
    \definecolor{c1}{rgb}{0,0,1}   %blue
     \definecolor{c2}{rgb}{0,0.3,0.9}   %light blue
      \definecolor{c3}{rgb}{0.3,0,0.9}   %red blue
        \definecolor{head}{RGB}{79, 129, 189}
        \begin{document}
            \begin{table}[!ht]
               \caption{\label{RCA} Les rôles du conseil d'administration}
              \centering
            \begin{tabularx}{\textwidth}{>{\columncolor[RGB]{79, 129, 189}}X|X|X}
           \toprule 
           \rowcolor{head}
           \multicolumn{1}{c}{\color{white}\textbf{\textsf{Théorie}}} &\multicolumn{1}{c}{\color{white}\textbf{\textsf{Rôle du conseil}}} & \multicolumn{1}{c}{\color{white}\textbf{\textsf{Trait dominant}}} \\
             \midrule
              \color{white} du capitalisme financier    & \cellcolor{head!10}Le conseil permet la cohésion du groupe et l'exercice du pouvoir. &\cellcolor{head!10}\\   
              \color{white} de la coordination/contrôle & Le conseil permet aux banques et aux familles de contrôle une société. & \multirow{3}{4.5cm}{\cellcolor{head!10}\textbf{Le conseil comme lieu d'exercice du pouvoir}} \\ 
      \color{white} de la cohésion sociale  & \cellcolor{head!10}Le conseil permet d'assurer la domination d'une classe sociale. & \cellcolor{head!10}\\
          \color{white} institutionnelle & Le conseil donne une image de la firme à son environnement. \newline Le conseil est un moyen pour l'entreprise de contrôler les ressources. & \textbf{Le conseil comme organe de médiation}\\    
          \color{white} légaliste & \cellcolor{head!10}Le conseil a pour vocation de protéger les intérêts des actionnaires. & \cellcolor{head!10}\\
         \color{white} managériale & Peu ou pas de rôle car le conseil est, de fait, manipulé par le dirigeant. &  \multirow{4}{4.5cm}{\cellcolor{head!10} \textbf{Le conseil comme lieu de contrôle}}\\
           \color{white} de l'agence &\cellcolor{head!10}Le conseil contrôle le dirigeant. & \cellcolor{head!10}\\
            \color{white} des coûts de transaction  &Gestion de la relation entre la firme, les actionnaires et les dirigeants. & \cellcolor{head!10}\\
           \bottomrule
            \hline
            \end{tabularx}

            \footnotesize Source: Le Joly (1998), Charreaux et Pitol-Belin (1990), Zahra et Pierce (1989)
               \end{table}
3
  • 1
    Do you want to centre vertically only the last column? Or also the first?
    – Bernard
    Jul 12, 2019 at 12:24
  • @Bernard yes why not! Thank you for your quick response :) Jul 12, 2019 at 12:29
  • I've posted an answer without vertically centring the first column cells. If you want to have this feature, you simply have to redefine the X column type as m{#1} instead of p{#1} (details in the package documentation).
    – Bernard
    Jul 12, 2019 at 13:24

2 Answers 2

2

Here is a solution: you had set as first parameter of \multirow the number of lines, not the number of rows, in the neighbouring cells. Also, instead of setting, more or less by trial and error, I suppose, the width of the multirow, as you're in a fixed width column, you can use {=} (this required slightly modifying the table preamble). To simplify a bit the code, I also used \columncolor for the last column. Last, I removed the thin white strips at the top and bottom of coloured cells, due to the vertical padding of the lines of booktabs, replacing it with extrarowheight. Loaded the caption package, to have a decent spacing between caption and table, and incorporated the ‘Sources’ as a last row (looks better left-aligned, in my opinion).

Unrelated: I don't sectsty and titlesec are very happy together, and similarly for enumerate and enumitem.

    \documentclass[oneside,a4paper,12pt, french]{book}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{libertine}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{emptypage} %prevents page numbers and heading appearing in empty pages
    \usepackage{babel}
    \usepackage[margin=2.5cm, top=3cm, headheight=26pt,headsep=25pt,heightrounded]{geometry}
    \frenchbsetup{FrenchFootnotes=false} %more common footnote style
    \usepackage[hang,flushmargin]{footmisc} % footnote presentation
    \usepackage{enumerate} % personnaliser les listes
    \usepackage[babel,french=guillemets]{csquotes}
    \usepackage{graphicx}
    \setcounter{tocdepth}{5} % level of sectionnin titles printed in TOC
    \setcounter{secnumdepth}{5} %sectionning titles are numbered: level 5
    \usepackage[titles]{tocloft} % nom du chapitre apparait en TOC
    \graphicspath{{\images}}
    \usepackage[dvipsnames,table]{xcolor}
    \usepackage{array,booktabs}
    \usepackage{xfrac}
    \usepackage{refcount}
    \usepackage{tikz}
    \usetikzlibrary{backgrounds}
    \usepackage{tikzpagenodes}
    \usepackage{xspace}
    \usepackage{setspace} %interligne 1.5
    \usepackage[parfill]{parskip} % espace entre deux paragraphes
    \usepackage{calc}
    \usepackage[explicit]{titlesec}
    \usepackage{shorttoc}
    \usepackage{enumitem} % modifier et personaliser les puces des listes
    \usepackage{pifont} % les symboles pour les listes
    \usepackage[french]{minitoc}
    \usepackage{etoolbox}
    \usepackage{sectsty}
    \allsectionsfont{\raggedright}
   \AtBeginEnvironment{footcitedquote}{\singlespacing\small}
   \AtBeginEnvironment{fancyquotes}{\small}
    %\setlength{\parskip}{10pt plus 1pt minus 1pt}}
    \setlength{\overfullrule}{5pt} % show the hfull and underfull vbox hbox warning

    \usepackage{smartdiagram}
    \usepackage{tabularx}
    \usepackage{multirow, caption}
    \setlength{\extrarowheight}{2pt}

% define colors
    \definecolor{c1}{rgb}{0,0,1} %blue
    \definecolor{c2}{rgb}{0,0.3,0.9} %light blue
    \definecolor{c3}{rgb}{0.3,0,0.9} %red blue
    \definecolor{head}{RGB}{79, 129, 189}

    \begin{document}
        \begin{table}[!ht]
           \caption{\label{RCA} Les rôles du conseil d'administration}
          \centering
        \setlength{\aboverulesep}{0pt}
        \setlength{\belowrulesep}{0pt}
        \begin{tabularx}{\textwidth}{>{\columncolor{head}}X|X| >{ \columncolor{head!10}\arraybackslash}X}%
       \toprule
       \rowcolor{head}
       \multicolumn{1}{c}{\color{white}\textbf{\textsf{Théorie}}} &\multicolumn{1}{c}{\color{white}\textbf{\textsf{Rôle du conseil}}} & \multicolumn{1}{c}{\color{white}\textbf{\textsf{Trait dominant}}} \\
       \arrayrulecolor{head!10} \midrule \arrayrulecolor{black}
          \color{white} du capitalisme financier & \cellcolor{head!10}Le conseil permet la cohésion du groupe et l'exercice du pouvoir. & \\
          \color{white} de la coordination/contrôle & Le conseil permet aux banques et aux familles de contrôle une société. & \multirow{3}{=}{\textbf{Le conseil comme lieu d'exercice du pouvoir}} \\
    \color{white} de la cohésion sociale & \cellcolor{head!10}Le conseil permet d'assurer la domination d'une classe sociale. & \\
      \color{white} institutionnelle & Le conseil donne une image de la firme à son environnement. \newline Le conseil est un moyen pour l'entreprise de contrôler les ressources. & \multirow{6}{=}{\cellcolor{white}\textbf{Le conseil comme organe de médiation}}\\
      \color{white} légaliste & \cellcolor{head!10}Le conseil a pour vocation de protéger les intérêts des actionnaires. & \\
     \color{white} managériale & Peu ou pas de rôle car le conseil est, de fait, manipulé par le dirigeant. &
     \\
       \color{white} de l'agence &\cellcolor{head!10}Le conseil contrôle le dirigeant. &\\
        \color{white} des coûts de transaction &Gestion de la relation entre la firme, les actionnaires et les dirigeants. & \multirow{-6}{=}{\textbf{Le conseil comme lieu de contrôle}}\\
       \bottomrule
        \hline
        \multicolumn{3}{@{}l}{\footnotesize Source: Le Joly (1998), Charreaux et Pitol-Belin (1990), Zahra et Pierce (1989)}
        \end{tabularx}

        \end{table}

        \end{document} 

enter image description here

9
  • thank you so much bernard :) it looks very good as i wanted. As for your unrelated remarks how can i fix it do i have to eliminate one of the packages Jul 12, 2019 at 13:28
  • Everything that enumerate does, enumitem can do it. As to sectsty and titlesec, it depends on what you want to do with them.
    – Bernard
    Jul 12, 2019 at 13:32
  • ah ok as for sectsty and titlesec can do the same? sorry for my questions I'm new to latex Jul 12, 2019 at 13:38
  • Can I ask you please a favor. Can I send you all my latex code for my thesis inculding macros....to see if I have somtehing Wrong in my packages....and your remarks especially about the page layout I really need someone to help me with that If it's ok I will really appreciated Jul 12, 2019 at 13:42
  • 1
    For the vertical rules, you have them, butas the colours slightly overlaps, your pdf viewer can hardly show them. You'll see them on zooming. However, if you want to see them with the default scaling, you replace | in the table preamble with |!{\vrule width 1pt}, or whatever thickness you please (default is 0.4pt). For \midrule, it is also there, but you can see it only at the bottom of the first column, because I changed its colour to the paler shade of blue used in the cells. For the email address, I'd prefer it remains private. But you can use something like WeTransfer or DropBox.
    – Bernard
    Jul 12, 2019 at 14:34
1

Like this?

enter image description here

\documentclass[oneside,a4paper,12pt]{book}
\usepackage[skip=1ex]{caption}
\usepackage[table]{xcolor}
% define colors
\definecolor{c1}{rgb}{0,0,1}        % blue
\definecolor{c2}{rgb}{0,0.3,0.9}    % light blue
\definecolor{c3}{rgb}{0.3,0,0.9}    % red blue
\definecolor{head}{RGB}{79, 129, 189}
\usepackage{ragged2e}
\usepackage{booktabs, multirow, tabularx}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{copyrightbox}

\begin{document}
    \begin{table}[!ht]
\renewcommand\tabularxcolumn[1]{m{#1}}
\caption{\label{RCA} Les rôles du conseil d'administration}
\centering
\copyrightbox[b]{\begin{tabularx}{\textwidth}{>{\columncolor[RGB]{79, 129, 189}\color{white}}L|
                             L|
                             >{\bfseries}L}
    \toprule
    \rowcolor{head}
\multicolumn{1}{c}{\color{white}\textbf{\textsf{Théorie}}}
    &   \multicolumn{1}{c}{\color{white}\textbf{\textsf{Rôle du conseil}}}
        &   \multicolumn{1}{c}{\color{white}\textbf{\textsf{Trait dominant}}} \\
    \midrule
du capitalisme financier
    &   \cellcolor{head!10}Le conseil permet la cohésion du groupe et l'exercice du pouvoir.
        &   \cellcolor{head!10}\\
de la coordination/contrôle
    & Le conseil permet aux banques et aux familles de contrôle une société.
        &   Le conseil comme lieu d'exercice du pouvoir \\
de la cohésion sociale
    & \cellcolor{head!10}Le conseil permet d'assurer la domination d'une classe sociale.
        &   \cellcolor{head!10}\\
%
institutionnelle
    &   Le conseil donne une image de la firme à son environnement.

        Le conseil est un moyen pour l'entreprise de contrôler les ressources.
            &   Le conseil comme organe de médiation    \\
légaliste
    &   \cellcolor{head!10}Le conseil a pour vocation de protéger les intérêts des actionnaires.
        &   \cellcolor{head!10}         \\
%
managériale
    &   Peu ou pas de rôle car le conseil est, de fait, manipulé par le dirigeant.
        &   \\
de l'agence
    &   \cellcolor{head!10}Le conseil contrôle le dirigeant.
        &   \cellcolor{head!10}
            Le conseil comme lieu de contrôle\\
des coûts de transaction
    &   Gestion de la relation entre la firme, les actionnaires et les dirigeants.
        &       \\
    \bottomrule
\end{tabularx}
    }{Source: Le Joly (1998), Charreaux et Pitol-Belin (1990), Zahra et Pierce (1989)}
   \end{table}
\end{document}

Note: coloring cells and use of booktabs doesn't work well together.

Edit: partly considered your comment below, partly my note above:

\documentclass[oneside,a4paper,12pt]{book}
\usepackage[skip=1ex]{caption}
\usepackage[table]{xcolor}
% define colors
\definecolor{c1}{rgb}{0,0,1}        % blue
\definecolor{c2}{rgb}{0,0.3,0.9}    % light blue
\definecolor{c3}{rgb}{0.3,0,0.9}    % red blue
\definecolor{head}{RGB}{79, 129, 189}
\usepackage{ragged2e}
\usepackage{booktabs, cellspace, multirow, tabularx}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\newcolumntype{L}{>{\RaggedRight}X}
\newcolumntype{C}{>{\Center}X}
\addparagraphcolumntypes{L}
\newcommand\mcbw[1]{\multicolumn{1}{>{\color{white}\bfseries\sffamily}Sc}{#1}}
\usepackage{boldline}
\usepackage{copyrightbox}

\begin{document}
    \begin{table}[!ht]
\renewcommand\tabularxcolumn[1]{m{#1}}
\caption{\label{RCA} Les rôles du conseil d'administration}
\centering
\copyrightbox[b]{
\begin{tabularx}{\textwidth}{|>{\columncolor[RGB]{79, 129, 189}\color{white}
                             \hsize=0.8\hsize}L|
                             >{\hsize=1.2\hsize}SL|
                             >{\bfseries}C|}
    \hlineB{2}
    \rowcolor{head}
\mcbw{Théorie}
    &   \mcbw{Rôle du conseil} 
        &   \mcbw{Trait dominant}   \\
    \hlineB{1}
du capitalisme financier
    &   \cellcolor{head!10}Le conseil permet la cohésion du groupe et l'exercice du pouvoir.
        &   \cellcolor{head!10}\\
de la coordination/contrôle
    & Le conseil permet aux banques et aux familles de contrôle une société.
        &   Le conseil comme lieu d'exercice du pouvoir \\
de la cohésion sociale
    & \cellcolor{head!10}Le conseil permet d'assurer la domination d'une classe sociale.
        &   \cellcolor{head!10}\\
%
institutionnelle
    &   Le conseil donne une image de la firme à son environnement.

        Le conseil est un moyen pour l'entreprise de contrôler les ressources.
            &   Le conseil comme organe de médiation    \\
légaliste
    &   \cellcolor{head!10}Le conseil a pour vocation de protéger les intérêts des actionnaires.
        &   \cellcolor{head!10}         \\
%
managériale
    &   Peu ou pas de rôle car le conseil est, de fait, manipulé par le dirigeant.
        &   \\
de l'agence
    &   \cellcolor{head!10}Le conseil contrôle le dirigeant.
        &   \cellcolor{head!10}
            Le conseil comme lieu de contrôle\\
des coûts de transaction
    &   Gestion de la relation entre la firme, les actionnaires et les dirigeants.
        &       \\
    \hlineB{2}
\end{tabularx}
    }{Source: Le Joly (1998), Charreaux et Pitol-Belin (1990), Zahra et Pierce (1989)}
   \end{table}
\end{document}
  • In both the MWEs above, I omit all packages from the preamble that I consider not relevant to the presented tables
  • I add the packages ragged2e for formatting cells' content, boldline (from the shipunov bundle) for table rules, cellspace for more vertical space and copyrightbox for note below table about table source.
  • With defined new column types and commands, I made table code slightly shorter and clearer.
  • Different column width (in the second MWE) is obtained by using \hsize=0.8\hsize for the first column, and \hsize=1.2\hsize for the second. You can change those ratios (or even change for the third columns) according to your needs. You should ensure that the numbers accumulate to an integer number.
  • I'm not sure, if the last column should be color head!10. If this is case, you just add \columncolor{head!10} to option of the last column and after remove all cell color commands from this column.

enter image description here

2
  • that looks good :) can u please make the text of the last column centered? And how can I get more space for the second column coz it has more text. I want the second column to be large than the others If you get what I mean Jul 12, 2019 at 13:02
  • thatnk you so much for your help :) Jul 12, 2019 at 14:32

You must log in to answer this question.

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