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

Torbjørn T.
  • 206,688
  • Could you be more explicit as to what you would like to have? – Bernard Dec 28 '16 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 '16 at 21:01
  • i want to make my table like this in photo (Red) – Trimi Volkswagen Dec 28 '16 at 21:02
  • This question need a description of what you what and what you did!! – bttX Dec 28 '16 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)

    – Trimi Volkswagen Dec 28 '16 at 21:12
  • If you want one Pauza instead of 5, use the multirow package. – John Kormylo Dec 28 '16 at 21:15
  • To all who voted to close this posting as a duplicate: I believe that's not warranted, as the OP is not actually trying to merge cells vertically. I've therefore re-opened the posting... – Mico Dec 28 '16 at 22:29
  • @TrimiVolkswagen - Just out of idle curiosity: Which language is this document set in? – Mico Dec 28 '16 at 22:34
  • @Mico in ALBANIAN – Trimi Volkswagen Dec 29 '16 at 00:26
  • I've noticed that while you've posted several questions so far and have received quite a few answers, you do not appear to have "accepted" any of the answers you may have found most useful. Upvoting good answers and accepting the best answers is the preferred way to show one's appreciation for the help one receives. – Mico Dec 29 '16 at 14:57

2 Answers2

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

egreg
  • 1,121,712
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}
Mico
  • 506,678