1

I want to add a caption below my table and my table is too aligned to the right, I want to bring it more to the left.

Here is the code of my table:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{array,booktabs}

% added packages and column definitions
\usepackage{ragged2e}           % for smart align of cells' content
    \usepackage{enumitem}       % for nice list
\newlist{tabitemize}{itemize}{1}% <-- defined new list
\setlist[tabitemize]{nosep,     % <-- new list setup
                     topsep     = 0pt       ,
                     partopsep  = 0pt       ,
                     leftmargin = *         ,
                     label      = $\bullet$ ,
                     before     = \vspace{-0.6\baselineskip},
                     after      = \vspace{-\baselineskip}
                     }
\newcolumntype{I}[1]{>{\RaggedRight\arraybackslash             % <-- for lists in columns
                    \tabitemize} p{#1}<{\endtabitemize}}
\newcommand\mch[1]{\multicolumn{1}{c}{\small{#1}}}  % <-- for columns headers  

\begin{document}
\newcommand*{\tstack}[1]{%
  \begingroup
    \renewcommand*{\arraystretch}{1}%
    \begin{tabular}[t]{@{}l@{}}#1\end{tabular}%
  \endgroup
}
\xdef\BaseLineSkip{\the\baselineskip}
\def\TableCaption{Légende de table}

\begin{tabular}{@{} >{\RaggedRight}p{4cm} *{2}{I{4cm}} @{}}
  \toprule
\mch{Méthode de validation}
    &   \mch{Avantages}   &   \mch{Inconvénients} \\
  \midrule
Resubstitution Validation
    &   \item simple
        \item effortles
        &    \item Surapprentissage                 \\
    \addlinespace
    \bottomrule
\end{tabular}
\end{document}

How can I add a caption after my table and adjust the table's alignment?

3
  • Where is the caption? – Bernard Jan 14 '17 at 22:32
  • But you say it is too aligned to the left! You must have put it somewhere to observe this. – Bernard Jan 14 '17 at 22:36
  • I mean the table is too aligned. – Joker 00 Jan 14 '17 at 22:58
1

enter image description here

For caption is the simplest way to put your table in table float environment and add caption:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{array,booktabs}

% added packages and column definitions
\usepackage{ragged2e}           % for smart align of cells' content
    \usepackage{enumitem}       % for nice list
\newlist{tabitemize}{itemize}{1}% <-- defined new list
\setlist[tabitemize]{nosep,     % <-- new list setup
                     topsep     = 0pt       ,
                     partopsep  = 0pt       ,
                     leftmargin = *         ,
                     label      = $\bullet$ ,
                     before     = \vspace{-0.6\baselineskip},
                     after      = \vspace{-\baselineskip}
                     }
\newcolumntype{I}[1]{>{\RaggedRight\arraybackslash             % <-- for lists in columns
                    \tabitemize} p{#1}<{\endtabitemize}}
\newcommand\mch[1]{\multicolumn{1}{c}{\small{#1}}}  % <-- for columns headers

\usepackage{showframe}% for show page layout
\renewcommand*\ShowFrameColor{\color{red}}

\begin{document}

    \begin{table}[htb]
    \centering %%%% <-- for horizontal centering table in text
\begin{tabular}{@{} >{\RaggedRight}p{4cm} *{2}{I{3.6cm}} @{}}
  \toprule
\mch{Méthode de validation}
    &   \mch{Avantages}   &   \mch{Inconvénients} \\
  \midrule
Resubstitution Validation
    &   \item simple
        \item effortles
        &    \item Surapprentissage                 \\
    \bottomrule
\end{tabular}
    \caption{My caption below table} %%%% <-- caption
\label{tab:items}
    \end{table}
\end{document}

Table was slightly wider than text width, therefore I reduce width of last two column. With \centering I horizontally center table in text area.

I delete all not relevant part of your code and add \usepackage{showframe} for showing page layout. In real use this package and following command had to be deleted.

0

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.