0

I'm a new with Latex, I'm trying to create my Thesis . But I'm stuck in how to create a table. I have tried to use this link which make latex tables online. but I didn't succeed to create my table with it .

I have this table :

enter image description here

could you help me please ?

1
  • Well, this is a screenshot, but does not reveal, what you did. Please post a compilable document. You need the c columntype and \multicolumn command (occasionally)
    – user31729
    Commented Jun 1, 2016 at 18:00

1 Answer 1

1

I would do it with tabularx and multirow. Note the first argument of \multirow is not the number of rows, but the number of lines, thus it really depends on the real contents of the rows, and requires an optional argument for a small correction. I also gave some vertical padding to the rows, setting \arraystretch to a value > 1.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage[showframe]{geometry}

\usepackage{array, tabularx, multirow}%
\newcolumntype{Y}{>{\hsize=.34\hsize\arraybackslash}X}
\newcolumntype{Z}{>{\hsize=.66\hsize\arraybackslash}X}

\begin{document}

\begin{table}[!htb]
  \centering\renewcommand\arraystretch{1.25}
  \begin{tabularx}{0.8\linewidth}{|Y|Y|Z|Z|}
    \hline
    \multicolumn{2}{|l|}{\bfseries Fonction} & \bfseries Description & \bfseries Degré  \\
    \hline
    \multirow{8}{\hsize}[1.2ex]{\centering Some labels (centred)} & A & I want this text to  be   justified & \multirow{8}{\hsize}[1.2ex] {\centering Some description (I want it to be centred)}
    \\
    \cline{2-3}
                                                                  & B & I want this text to  be   justified &                                                                                     \\
    \cline{2-3}
                                                                  & C & I want this text to  be  justified  &                                                                                     \\
    \cline{2-3}
                                                                  & D & I want this text to  be  justified  &                                                                                     \\
    \hline
    \multicolumn{2}{|l|}{Some labels} &  I want this text to  be  justified  & Some labels \\
    \hline
  \end{tabularx}
\end{table}

\end{document} 

enter image description here

7
  • sorry but is there a way to make this table span into two pages . ( it's long with my data ) ?
    – pietà
    Commented Jun 6, 2016 at 10:00
  • Yes: load ltablex instead of tabularx. It combines the functionalities of tabularx and longtable (a caption must be set in the way longtable does).
    – Bernard
    Commented Jun 6, 2016 at 10:17
  • thanks for your reply .. I have changed to ltablex and added this package \usepackage{ltablex} but i got errors .. do table allow this separation into 2 pages .?
    – pietà
    Commented Jun 6, 2016 at 10:24
  • 1
    I think not. Forr longtable, one doesn't use it. A priori, when you split a table across pages, you don't want it to float. So replace table with center (and delete \centering): If you need a cation, use \captionof[table]{…}.
    – Bernard
    Commented Jun 6, 2016 at 10:28
  • thank you for your directions :) I have used tabularx and changed begin{center} as you have suggested . because ltablex generates errors it works now :)
    – pietà
    Commented Jun 6, 2016 at 10:41

You must log in to answer this question.

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