Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to merge column in LaTeX. I can make that but this line is incomplete because it still open on the left. Perhaps you will not understand what I mean, but this is the code that I wrote

\documentclass{article}
\usepackage{array}

\usepackage[french]{babel}

\begin{document}    \begin{table}[!h]
\begin{center}
\begin{tabular}{|c|c|c|c|} 
%\begin{tabular}{|p{2cm}|p{2.1cm}|p{3.5cm}|p{3.3cm}|p{1.6cm}|p{1.7cm}|p{1.7cm}|}
  \hline
 \bf Id Page  & \bf Politique de Partage & \bf Nombre Amis & \bf Nombre Pages qui ont reçu la pub \\
  \hline
   78 & Amis Seulement & 23&23 \\
   81&Amis Seulement&25&25\\
   65&Amis Seulement&25&25\\
   59&Amis et leurs Amis&26&51\\
   16&Tout le Monde&27&100\\
   45&Amis et leurs Amis&27&71\\
   69&Amis Seulement&27&27\\
   74&Amis Seulement&27&27\\
   99&Amis Seulement &27&27\\
   30&Amis et leurs Amis&27&64\\


   \hline
   \multicolumn{3}{|c|}{Moyenne des pages qui ont reçu  }

    \\
    \hline  
\end{tabular}
\end{center}
\bf {\caption{Publication partagée avec une page ayant un nombre minimal d'amis dans réseau 1}}
\end{table}
\end{document}
share|improve this question
3  
No, sorry. It's rather difficult to understand. May you expand a bit? –  egreg Apr 24 '12 at 22:09
    
when I want that my ligne in my table is constructed with 2 column one it is merged and the other isn't merged and corresponding to my code the second column isn't closed. –  boutheina Apr 24 '12 at 22:13
    
Please, show some code rather than trying to explain in that way. –  egreg Apr 24 '12 at 22:15
1  
@boutheina: It would be really helpful if you could just make a small example document. –  Jake Apr 24 '12 at 22:16
add comment

1 Answer 1

Leaving out column separations & for columns that contain nothing doesn't always have the desired effect when you include vertical lines:

enter image description here

\documentclass{article}
\begin{document}
\begin{tabular}{|*{4}{c|}}
  One & Two & Three & Four \\
  \multicolumn{3}{|c|}{OneTwoThree} \\
  One & Two & Three & Four
\end{tabular}

\bigskip

\begin{tabular}{|*{4}{c|}}
  One & Two & Three & Four \\
  \multicolumn{3}{|c|}{OneTwoThree} & \\
  One & Two & Three & Four
\end{tabular}
\end{document}​

As such, include a single & (or as many as is required, like in the last tabular) to add the final vertical line, "closing" the row.


Here is an updated view of your minimal working example:

enter image description here

\documentclass{article}
%\usepackage{array}% http://ctan.org/pkg/array
%\usepackage[french]{babel}% http://ctan.org/pkg/babel
\begin{document}
\begin{table}[!h]
  \centering % \begin{center}
  \begin{tabular}{|c|c|c|c|} 
  %\begin{tabular}{|p{2cm}|p{2.1cm}|p{3.5cm}|p{3.3cm}|p{1.6cm}|p{1.7cm}|p{1.7cm}|}
    \hline
    \bfseries Id Page  & \bfseries Politique de Partage & \bfseries Nombre Amis & \bfseries Nombre Pages qui ont reçu la pub \\
    \hline
    78 & Amis Seulement     & 23 &  23 \\
    81 & Amis Seulement     & 25 &  25 \\
    65 & Amis Seulement     & 25 &  25 \\
    59 & Amis et leurs Amis & 26 &  51 \\
    16 & Tout le Monde      & 27 & 100\\
    45 & Amis et leurs Amis & 27 &  71 \\
    69 & Amis Seulement     & 27 &  27 \\
    74 & Amis Seulement     & 27 &  27 \\
    99 & Amis Seulement     & 27 &  27 \\
    30 & Amis et leurs Amis & 27 &  64 \\
    \hline
    \multicolumn{3}{|c|}{Moyenne des pages qui ont re\c{c}u  } & \\ % <---- inserted &
    \hline  
  \end{tabular}
  %\end{center}
  \caption{Publication partag\'ee avec une page ayant un nombre minimal d'amis dans r\'eseau 1}
\end{table}
\end{document}​

Some comments regarding your table construction:

share|improve this answer
    
I don't understand well what do you mean if I merge colums it doesn't be closed? –  boutheina Apr 24 '12 at 22:44
    
@boutheina: In your example your only merging the first 3 (of 4) columns. Ending the table row after only 3 columns (using \\ ) leave the first column "unused", and (La)TeX therefore doesn't insert the last vertical rule. If you use \multicolumn{3}{|c|}{Moyenne des pages qui ont reçu } & for your merged column, the final column in that row will "close" the row with a vertical rule, as specified by the original column specification (|c|c|c|c|). –  Werner Apr 24 '12 at 22:47
1  
:please I don't understand what do you mean can you please write this? –  boutheina Apr 24 '12 at 22:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.