3

I am trying to do a table in latex. My problem is I cannot to a multirow for "Apprentissage" cell between the 3 cell : "phrase", "mot" and "vocabulaire"

\begin{figure}
\centering
\begin{tabular}{|c|c|c|c|c|}
 \hline
 \multicolumn{2}{|c|}{Corpus} & Français & Anglais & Allemand   \\ \hline
\multirow{3}{*}{Apprentissage} & phrases & \multicolumn{3}{c|}{600.000} \\ \hline
&   Mot & ? & ? & ? \\ \hline
& Vocabulaire & ? & ? & ? \\
\hline
\end{tabular}
\caption{Caractéristique du corpus \textsc{Europarl}}
\label{fig:typeDistribution}
\end{figure}

Any idea please?

4 Answers 4

3

Use \cline{n-m} instead of \hline.

 \begin{figure}
 \centering
 \begin{tabular}{|c|c|c|c|c|}
  \hline
  \multicolumn{2}{|c|}{Corpus} & Français & Anglais & Allemand   \\ \hline
 \multirow{3}{*}{Apprentissage} & phrases & \multicolumn{3}{c|}{600.000} \\ \cline{2-5}
 &   Mot & ? & ? & ? \\ \cline{2-5}
 & Vocabulaire & ? & ? & ? \\
 \hline
 \end{tabular}
 \caption{Caractéristique du corpus \textsc{Europarl}}
 \label{fig:typeDistribution}
 \end{figure}
2

Multirow doesn't override \hline. Instead of them, you should use \cline:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{multirow}

\begin{document}
\begin{figure}
    \centering
\begin{tabular}{|c|c|c|c|c|}
    \hline
\multicolumn{2}{|c|}{Corpus}    & Français  & Anglais   & Allemand   \\ \hline
\multirow{3}{*}{Apprentissage}  & phrases   & \multicolumn{3}{c|}{600.000}  \\ \cline{2-5}
                                & Mot & ? & ? & ?                           \\ \cline{2-5}
                                & Vocabulaire & ? & ? & ?                   \\ \hline
\end{tabular}
\caption{Caractéristique du corpus \textsc{Europarl}}
\label{fig:typeDistribution}
\end{figure}
\end{document}

enter image description here

8
  • 1
    Your "français" is missing the ç. :P
    – Alenanno
    May 17, 2015 at 17:59
  • I see. Since I need to construct MWE myself, I didn't pay attention on French langue, i.e. adequate font coding ... I will try to correct this.
    – Zarko
    May 17, 2015 at 18:13
  • 1
    I think adding \usepackage[utf8]{inputenc} should be enough! :)
    – Alenanno
    May 17, 2015 at 18:15
  • Yes, it is. Anyway I also added \usepackage[T1]{fontenc}. To be MWE more complete :-). Can you me tell, how you highlight latex code in your comment. I like to do on the same way, but for now I unsuccessfully search how to do this ...
    – Zarko
    May 17, 2015 at 18:17
  • You need to use back ticks, like ``. Add the word(s) in the middle.
    – Alenanno
    May 17, 2015 at 18:22
1

Here is a way to create that table with {NiceTabular} of nicematrix.

In {NiceTabular}, you merge cells both horizontally and vertically with the command \Block. For the rows, you give the number of logical rows (and not the number of physical lines as with \multirow).

With the key hvlines, all the rules are drawn, except in the blocks (constructed by \Block).

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table}
\centering
\begin{NiceTabular}{ccccc}[hvlines]
\Block{1-2}{Corpus}        &             & Français             & Anglais & Allemand   \\ 
\Block{3-1}{Apprentissage} & phrases     & \Block{1-3}{600.000} \\ 
                           & Mot         & ?                    & ?       & ? \\ 
                           & Vocabulaire & ?                    & ?       & ? \\ 
\end{NiceTabular}
\caption{Caractéristique du corpus \textsc{Europarl}}
\label{fig:typeDistribution}
\end{table}

\end{document}

Output of the above code

0

You might use array in order to get correct corners and \cline{2-5} in between the rows that are affected by \multirow.

But the table (not figure) you get is difficult to read, because headers refer to what's below them, not next to them, so your “Corpus” refers to “Apprentissage” and the column with the items.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\usepackage{array}
\usepackage{multirow} % for the bad table
\usepackage{booktabs} % for the good table

\begin{document}

\begin{table}[htp]
\centering

\begin{tabular}{|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Corpus} & Français & Anglais & Allemand \\
\hline
\multirow{3}{*}{Apprentissage} & phrases & \multicolumn{3}{c|}{600.000} \\
\cline{2-5}
 &   Mot & ? & ? & ? \\
\cline{2-5}
 & Vocabulaire & ? & ? & ? \\
\hline
\end{tabular}

\caption{Caractéristique du corpus \textsc{Europarl}}
\label{fig:typeDistribution}

\end{table}

\begin{table}[htp]
\centering

\begin{tabular}{@{}lccc@{}}
\toprule
Apprentissage & \multicolumn{3}{c@{}}{Corpus} \\
\cmidrule(l){2-4}
 & Français & Anglais & Allemand \\
\midrule
Phrases     & \multicolumn{3}{c@{}}{600\,000} \\
Mot         & ? & ? & ? \\
Vocabulaire & ? & ? & ? \\
\bottomrule
\end{tabular}

\caption{Caractéristique du corpus \textsc{Europarl}}
\label{fig:typeDistribution-improved}

\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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