4

I want to make a table like the image below, i.e. I need to merge the cells under 12- and 1-2.

Thank you and sorry but I don't speak english (sorry for my english)

\begin{table}[ht]
 \centering
 \label{my-label}
\begin{tabular} {|p{2cm}||p{1.3cm}|p{1.5cm}|p{2.2cm}|p{1.3cm}|p{1.3cm}|p{1.5cm}|p{1.3cm}|  }
 \hline
Dita/Koha & 9-10 & 10-11 & 11-12 & 12-1 &1-2 & 2-3 & 3-4 \\ [1.5ex] 
\hline\hline
E hene & Analiza & Topologji & Alg.Geometri & Pauza & & Algjelbra &  \\  [1.0ex] 
\hline
E Marte & \multicolumn{3}{| c |}{Provimi} &Pauza  & & \multicolumn{2}{| c |}{Aplikimi i Softuerit}    \\ [1.5ex] 
\hline
E Merkure & Analiza & Topologji & Alg.Geometri & Pauza &  & Algjelbra &\\[1.5ex] 
\hline
E Enjete &\multicolumn{3}{| c |}{Provimi} &Pauza  & &\multicolumn{2}{| c |}{Aplikimi i Softuerit} \\ [1.5ex] 
\hline
 E Premte & Analiza & Topologji & Alg.Geometri & Pauza &  & Algjelbra &  \\ [1.5ex] 
\hline
 E Shtune & \multicolumn{7}{| c |}{Vikendi} \\ [2.5ex] 
 \hline
E Dielle & \multicolumn{7}{| c |}{Vikendi}    \\ [2.5ex] 
 \hline
 \end{tabular}
 \end{table}

i have to do like this in photo

10
  • Could you be more explicit as to what you would like to have?
    – Bernard
    Dec 28, 2016 at 21:01
  • your table is to wide for portrait page orientation. even if I reduce font size to \footnotesize. You need to consider to change page orientation to landscape.
    – Zarko
    Dec 28, 2016 at 21:01
  • i want to make my table like this in photo (Red) Dec 28, 2016 at 21:02
  • This question need a description of what you what and what you did!!
    – bttX
    Dec 28, 2016 at 21:05
  • WHAT I WANT IS LIKE IN PHOTO WHAT I NEED IS TO MERGE CELLS UNDER 12- AND 1-2 thank you and sorry but i dont speak english (sorry for my english) Dec 28, 2016 at 21:12

2 Answers 2

3

Use \multicolumn again!

Note that the rules should not be duplicated, so it is \multicolumn{2}{c|}{...}.

It's also better to make a macro out of repetitive jobs.

\documentclass{article}
\usepackage{array}

\newcommand{\Provimi}{\multicolumn{3}{c|}{Provimi}}
\newcommand{\Pauza}{\multicolumn{2}{c|}{Pauza}}
\newcommand{\Vikendi}{\multicolumn{7}{c|}{Vikendi}}

\begin{document}

\begin{center}

\setlength{\extrarowheight}{1.5ex}
\addtolength{\tabcolsep}{-3.5pt}

\begin{tabular} {|l|*{7}{c|}}
\hline
Dita/Koha & 9-10 & 10-11 & 11-12 & 12-1 &1-2 & 2-3 & 3-4 \\ [1.5ex] 
\hline\hline
E \textsc{hene} & Analiza & Topologji & Alg.\@ Geometri & \Pauza & Algjelbra &  \\  [1.5ex] 
\hline
E \textsc{marte} & \Provimi &\Pauza & \multicolumn{2}{c|}{Aplikimi i Softuerit}    \\ [1.5ex] 
\hline
E \textsc{merkure} & Analiza & Topologji & Alg.\@ Geometri & \Pauza & Algjelbra &\\[1.5ex] 
\hline
E \textsc{enjete} &\Provimi & \Pauza &\multicolumn{2}{c|}{Aplikimi i Softuerit} \\ [1.5ex] 
\hline
E \textsc{premte} & Analiza & Topologji & Alg.\@ Geometri & \Pauza & Algjelbra &  \\ [1.5ex] 
\hline
E \textsc{shtune} & \Vikendi \\ [1.5ex] 
\hline
E \textsc{dielle} & \Vikendi \\ [1.5ex] 
\hline
\end{tabular}

\end{center}

\end{document}

The setting to \tabcolsep is to avoid an overfull box; it might be not necessary in your case, depending on the global text width.

enter image description here

2
  • 1
    Is there even a point in having separate columns for "12-1" and "1-2"?
    – Mico
    Dec 28, 2016 at 22:33
  • @Mico Only one hour slots are allocated
    – egreg
    Dec 28, 2016 at 23:32
0

I would merge the two columns labeled "12-1" and "1-2" directly, i.e., I would provide only 1 column with label "12-2".

There's no aim to allow line breaks in any of the cells, is there? If there's not, I'd use a simple c column type instead of p column types.

enter image description here

\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[ht]
\setlength\extrarowheight{4pt}
\setlength\tabcolsep{4pt}
 \centering
\caption{A timetable} \label{my-label}
\begin{tabular} {|l||*{6}{c|}}
 \hline
Dita/Koha & 9--10 & 10--11 & 11--12 & 12--2 & 2--3 & 3--4 \\ [1ex] 
\hline\hline
E hene    & Analiza & Topologji & Alg.Geometri & Pauza & Algjelbra &  \\  [1.0ex] 
\hline
E Marte   & \multicolumn{3}{c|}{Provimi}       & Pauza & \multicolumn{2}{c|}{Aplikimi i Softuerit}    \\ [1ex] 
\hline
E Merkure & Analiza & Topologji & Alg.Geometri & Pauza & Algjelbra & \\[1ex] 
\hline
E Enjete  &\multicolumn{3}{c|}{Provimi}        & Pauza & \multicolumn{2}{c|}{Aplikimi i Softuerit} \\ [1ex] 
\hline
 E Premte & Analiza & Topologji & Alg.Geometri & Pauza & Algjelbra & \\ [1ex] 
\hline
 E Shtune & \multicolumn{6}{c|}{Vikendi} \\ [1ex] 
 \hline
E Dielle  & \multicolumn{6}{c|}{Vikendi} \\ [1ex] 
 \hline
\end{tabular}
\end{table}
\end{document}

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.