1

In this table the vertical lines in the header are shifted

\documentclass{article}
\usepackage{array,multirow}
\usepackage{multicol}
\usepackage{graphicx}
\begin{document}

\begin{table}
\begin{center}
    \scriptsize
\begin{tabular}{|m{0.3cm}|m{3cm}|m{2cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|}
    \cline{4-11} 
    \multicolumn{3}{r}{} & \multicolumn{5}{|r|}{\bf Actividades presenciales} & \multicolumn{3}{r|}{\multirow{2}{*}{\textbf{No presenciales}}} \\
    \cline{4-8} 
    \multicolumn{3}{r}{} & \multicolumn{3}{|r}{\textbf{Convencionales}} & \multicolumn{2}{|r|}{\textbf{No conv.}} &
    \multicolumn{3}{|r|}{}
    \\ \hline
\rotatebox[origin=c]{90}{\textbf{Semana}}     & \textbf{Contenidos de teoría} & \textbf{Clases prácticas} &
\rotatebox[origin=c]{90}{\textbf{Clase de teoría}} & \rotatebox[origin=c]{90}{\textbf{Clase de problemas}} &
\rotatebox[origin=c]{90}{\textbf{Clase de prácticas}} & \rotatebox[origin=c]{90}{\textbf{Presentación trabajos}} &
\rotatebox[origin=c]{90}{\textbf{Examen}} & \rotatebox[origin=c]{90}{\textbf{Estudio}} & 
\rotatebox[origin=c]{90}{\textbf{Elaboración cuestionarios}} & \rotatebox[origin=c]{90}{\textbf{Elaboración proyecto}}   
 \\\hline
1 &  Introducción. UD 1: 1.1               & Práctica 0  & &  & &  & &  & &  \\ \hline % ISLA
2 &  UD 1: 1.2, 1.3                        & Practica 1 & 2 &   & 3 &  &  & 4  & & \\ \hline % SNMP
3 &  Ejercicios UD 1: 1.3                  & Práctica 2 & 1 & 1 & 3 &  &  & 4  & & \\ \hline % Cacti
4 &  UD 1: 1.4                             & Práctica 3 & 2 &   & 3 &  &  & 4 & 2 & \\ \hline % RMON
5 &  UD 1: 1.5, Ejercicios UD 1: 1.1 a 1.4 & Práctica 4 & 1 & 1 & 3 &  &  & 5 &   & 10 \\ \hline % Netflow
6 &  UD 1: 1.6                             & Práctica 5 & 2 &   & 3 &  &  & 5 & 2 & 10 \\ \hline % RPC protocols
7 &  UD 1: 1.6                             & Práctica 6 & 2 &   & 3 &  &  & 5 &   & 10 \\ \hline % NAPALM
8 &  PARCIALES &   &  &  &  &  & 2.5 & 10   & &    \\ \hline
9 &  UD 2: 2.1          & Práctica 7 & 2 &  & 3 &  &  & 1 & &  \\ \hline
10 & UD 2: 2.2          & Práctica 8 & 2 &  & 3 &  &  & 4 & &  \\ \hline
11 & UD 2: 2.2          & Práctica 9  & 2 &  & 3 &  &  & 4 & & \\ \hline
12 & UD 2: 2.2          & Práctica 10 & 2 &  & 3 &  &  & 4 & 4 & \\ \hline
13 & UD 2: 2.3          & Práctica 11  & 2 &  & 3 &  &  & 5 & 2 & 10 \\ \hline
14 & UD 2: 2.4          & Práctica 12 & 2 &  & 3 &  &  & 5 & 3 & 10 \\ \hline
15 & UD 2: 2.5          &  &  &  & 3 & 2 &  & 5 & 2 & 10 \\ \hline
16 & PARCIALES &  &  &  &  &  & 2.5 & 10 & & \\ \hline
 & & Total Horas: & 24 & 2 & 42 & 2 & 5 & 75 & 15 & 60 \\ \hline
\end{tabular}
\caption{My table}
\label{TRABAJOTABLA}
\end{center}
\end{table}

\end{document}

which results:

enter image description here

I would like to draw the vertical separation lines of the table header aligned with the row below (zoom here):

enter image description here

In the above picture the left line of Convencionales and Actividades is shifted slightly to the right. This is likely due to the empty multicolumn `\multicolumn{3}{r}{}'.

EDIT I am using this preamble:

\documentclass[a4paper,12pt,twoside,openright]{report}
\usepackage[nottoc,numbib]{tocbibind}
\usepackage[utf8]{inputenc}
\usepackage[spanish,es-tabla]{babel}
\usepackage[T1]{fontenc}
\usepackage{times}
%\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{eurosym}
\usepackage{epigraph}
%\usepackage{vmargin}
\usepackage{graphicx}
\graphicspath{{_figs/}{_fig_logos/}{_figs/_chap5_jva/}}
%\setpapersize{A4}
%\setmarginsrb{30mm}{20mm}{20mm}{20mm}{0pt}{0mm}{0pt}{0mm}
\usepackage{xspace}
\usepackage{multicol}
\usepackage{array, makecell, multirow}
\usepackage{tabularx}
\usepackage{color, colortbl}
% \usepackage{cleveref}
\usepackage{titlesec} 
%\usepackage{charter}
\usepackage[bitstream-charter]{mathdesign}
\usepackage{XCharter}
%
\usepackage{fancyhdr}
\usepackage{lastpage}
%%% --  ---
% \usepackage{multirow}
\usepackage[dvipsnames]{xcolor}
%

\makeatletter   
% https://tex.stackexchange.com/questions/319768/
                % are-m-column-type-and-makecell-incompatible/319775#319775
\renewcommand\mcell@classz{\@classx
   \@tempcnta \count@
   \prepnext@tok
   \@addtopreamble{%\mcell@mstyle
      \ifcase\@chnum
         \hfil
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hskip1sp
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hfil\hskip1sp
         \mcell@agape{\d@llarbegin \insert@column\d@llarend}\or
         \mcell@agape{$\vcenter
         \@startpbox{\@nextchar}\insert@column\@endpbox$}\or
         \mcell@agape{\vtop
         \@startpbox{\@nextchar}\insert@column\@endpbox}\or
         \mcell@agape{\vbox
         \@startpbox{\@nextchar}\insert@column\@endpbox}%
      \fi
      \global\let\mcell@left\relax\global\let\mcell@right\relax
    }\prepnext@tok}
\makeatletter
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{}
\NewExpandableDocumentCommand\mcbf{O{1}m}{\multicolumn{#1}{>{\bfseries}c|}{#2}}


\usepackage[margin=30mm]{geometry}
\usepackage{verbatim,synttree,pdfpages,enumerate,multicol}
\usepackage[pagebackref,colorlinks,urlcolor=blue,citecolor=blue,linkcolor=blue]{hyperref}

\usepackage{cleveref}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}

\fancyhead[RE,LO]{Proyecto Docente}

\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyfoot[RO]{\thepage\ de \pageref*{LastPage}}%
  \fancyfoot[LO]{Pablo López-Matencio Pérez}%
  \renewcommand{\headrulewidth}{0pt}% Line at the header invisible
  \renewcommand{\footrulewidth}{0.4pt}% Line at the footer visible
}
 

\fancypagestyle{toc}{%
  \fancyhf{}%
  \fancyfoot[RO]{\thepage}%
  \renewcommand{\headrulewidth}{0pt}% Line at the header invisible
  \renewcommand{\footrulewidth}{0.4pt}% Line at the footer visible
}
\addtocontents{toc}{\protect\thispagestyle{toc}}

\setcounter{secnumdepth}{4}
\definecolor{Gray}{gray}{0.8}

\crefname{table}{tabla}{tablas}

\newcommand{\fakechap}[1]{{\noindent\normalfont\sectfont\nobreak\size@chapter{}#1\par}\chapterheadendvskip\noindent\ignorespaces}
\makeatother

2 Answers 2

1

You may liked the following table format:

enter image description here

With use of multicell and rotating packages, defining \multicolumn cells with vertical lines only on the right side of cells and added fix for m column type at use of the \makegapedecells macro from the \makecell package:

\documentclass{article}
\usepackage{rotating}
\usepackage{array, makecell, multirow}
\makeatletter   % https://tex.stackexchange.com/questions/319768/
                % are-m-column-type-and-makecell-incompatible/319775#319775
\renewcommand\mcell@classz{\@classx
   \@tempcnta \count@
   \prepnext@tok
   \@addtopreamble{%\mcell@mstyle
      \ifcase\@chnum
         \hfil
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hskip1sp
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hfil\hskip1sp
         \mcell@agape{\d@llarbegin \insert@column\d@llarend}\or
         \mcell@agape{$\vcenter
         \@startpbox{\@nextchar}\insert@column\@endpbox$}\or
         \mcell@agape{\vtop
         \@startpbox{\@nextchar}\insert@column\@endpbox}\or
         \mcell@agape{\vbox
         \@startpbox{\@nextchar}\insert@column\@endpbox}%
      \fi
      \global\let\mcell@left\relax\global\let\mcell@right\relax
    }\prepnext@tok}
\makeatletter
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{}
\NewExpandableDocumentCommand\mcbf{O{1}m}{\multicolumn{#1}{>{\bfseries}c|}{#2}}



\begin{document}
    \begin{table}
\centering
\footnotesize
\settowidth\rotheadsize{\theadfont cuestionarios}
\setcellgapes{3pt}
\makegapedcells
\begin{tabular}{|c|m{3cm}|m{2cm}|
                       *{8}{w{c}{2em}|}}   %m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|}
    \Xcline{4-11}{0.9pt}
\mcbf[3]{}
    &   \mcbf[5]{Actividades presenciales}
        & \mcbf[3]{\multirow{2.4}{*}{No presenciales}}                  \\
    \cline{4-8}
\mcbf[3]{}
    &   \mcbf[3]{Convencionales}
        &   \mcbf[2]{No conv.}
            &   \mcbf[3]{}                                              \\
        \Xhline{0.8pt}
\rothead{Semana}
    & \thead{Contenidos\\ de teoría}
        & \thead{Clases\\ prácticas}
            &   \rothead{Clase de\\ teoría}
                &   \rothead{Clase de\\ problemas}
                    &   \rothead{Clase de prácticas}
                        &   \rothead{Presentación\\ trabajos}
                            &   \rothead{Examen}
                                &   \rothead{Estudio}
                                    &   \rothead{Elaboración\\ cuestionarios}
                                        &   \rothead{Elaboración\\ proyecto}  \\
    \Xhline{0.6pt}
1   &  Introducción. UD 1: 1.1
        & Práctica 0
            &   &   &   &   &   &   &   &   \\
    \hline % ISLA
2   &  UD 1: 1.2, 1.3
        &   Practica 1
            & 2 &   & 3 &   &   & 4  &  &   \\
    \hline % SNMP
3   &   Ejercicios UD 1: 1.3                  
        & Práctica 2 
            & 1 & 1 & 3 &   &   & 4 &   &   \\ \hline % Cacti
4   &  UD 1: 1.4                             
        & Práctica 3
            & 2 &   & 3 &   &   & 4 & 2 &   \\ \hline % RMON
5   &  UD 1: 1.5, Ejercicios UD 1: 1.1 a 1.4 
        & Práctica 4 
            & 1 & 1 & 3 &   &   & 5 &   & 10 \\ \hline % Netflow
6   &  UD 1: 1.6                             
        & Práctica 5 
            & 2 &   & 3 &   &   & 5 & 2 & 10 \\ \hline % RPC protocols
7   &  UD 1: 1.6                             
        &   Práctica 6 
            & 2 &   & 3 &   &   & 5 &   & 10 \\ \hline % NAPALM
8   &  PARCIALES 
        &   &   &   &   &   & 2.5   & 10    &   &   \\ \hline
9   &  UD 2: 2.1
        & Práctica 7 
            & 2 &   & 3 &   &   & 1 &   &  \\ \hline
10  & UD 2: 2.2          
        & Práctica 8 
            & 2 &   & 3 &   &   & 4 &   &  \\ \hline
11  & UD 2: 2.2          
        & Práctica 9  
            & 2 &   & 3 &   &   & 4 &   & \\ \hline
12  & UD 2: 2.2          
        & Práctica 10 
            & 2 &   & 3 &   &   & 4 & 4 & \\ \hline
13  & UD 2: 2.3          
        & Práctica 11  
            & 2 &   & 3 &   &   & 5 & 2 & 10 \\ \hline
14  & UD 2: 2.4          
        & Práctica 12 
            & 2 &   & 3 &   &   & 5 & 3 & 10 \\ \hline
15  & UD 2: 2.5          
        &   &   &   & 3 & 2 &  & 5 & 2 & 10 \\ \hline
16  & PARCIALES 
        &   &   &   &   &   & 2.5   & 10    &   & \\ \hline
    &   & Total Horas: 
        & 24 & 2 & 42 & 2 & 5 & 75 & 15 & 60 \\ 
    \Xhline{0.9pt}
\end{tabular}
\caption{Trabajo tabla}
\label{TRABAJOTABLA}
    \end{table}
\end{document}
4
  • I have pasted the solution but the headers does not rotate. I am going to add all the preamble my TeX has. May you check if there is compatible with the others packages? Apr 27, 2021 at 8:53
  • @user1993416, in your premble you forgot to add package rotating (before makecell). Alcso consider to check it again. You load some packages twice ...
    – Zarko
    Apr 27, 2021 at 9:09
  • It works fine. I was using \rowcolor{Gray} in the header row and the bottom row (Total:), but now it does not work. If allowed here, how could I set a background color to those cells?. Apr 27, 2021 at 9:18
  • In your question is not mentioned, that you like to have colored rows in this table . Using \makegapedcell is not compatible with coloring of rows, i.e. it remove colors. For start remove this instruction. If this gives you satisfactory result, than this is fix, but if you still like increase vertical gapes around cells contents, you can do this by use of the cellspace package. Example of use you can see in tex.stackexchange.com/questions/281485
    – Zarko
    Apr 27, 2021 at 9:44
1

Put the | in \multicolumn on the other side of the r.

\begin{tabular}{|m{0.3cm}|m{3cm}|m{2cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|m{.5cm}|}
    \cline{4-11} 
    \multicolumn{3}{r|}{} & \multicolumn{5}{r|}{\bf Actividades presenciales} & \multicolumn{3}{r|}{\multirow{2}{*}{\textbf{No presenciales}}} \\
    \cline{4-8} 
    \multicolumn{3}{r|}{} & \multicolumn{3}{r|}{\textbf{Convencionales}} & \multicolumn{2}{r|}{\textbf{No conv.}} &
    \multicolumn{3}{r|}{}
    \\ \hline
 . . .

enter image description here

You must log in to answer this question.

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