3

I'm having trouble to insert a table in an article. My article has 2 tables.

I want to put 2 columns length on one table. Which I could achieve, but it is cutting the line.

See the image below.

enter image description here

The code is:

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ll|lllll|llll|llll|l|}
\cline{3-16}
                                                                                                   &             & \multicolumn{5}{c|}{\begin{tabular}[c]{@{}c@{}}Compassos com \\ pausas (CV; \%)\end{tabular}} & \multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Notas Usadas\\  (NCN)\end{tabular}} & \multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Qualidade das \\ Notas (NQ; \%)\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Razão de Intervalos \\ RI(\%)\end{tabular}} \\
                                                                                                      &             & S             & Pe            & V            & Pi          & C                                & S                  & V                  & Pi                  & C                  & S                     & V                     & Pi                    & C                    & Pe                                                                                         \\ \hline
\multicolumn{2}{|l|}{Dados de treinamento}                                                                            & 13.06         & 13.06         & 24.4         & 29.8        & 15.1                             & 6.71               & 8.08               & 8.28                & 8.38               & 95                    & 86.9                  & 93.4                  & 94.6                 & 93.6                                                                                       \\ \hline
\multicolumn{1}{|l}{\multirow{4}{*}{\begin{tabular}[c]{@{}l@{}}Composição\\   do zero\end{tabular}}}   & Simplificado & 97.4          & 100           & 17.5         & 5.68        & \multicolumn{1}{c|}{5.00}        & 6                  & 7.88               & 7.32                & 9.72               & 5                     & 27.8                  & 36.1                  & 31.2                 & 5                                                                                          \\
\multicolumn{1}{|l}{}                                                                                  & Improviso    & 11.59         & 7.33          & 23.3         & 27.6        & 11.1                             & 6.53               & 8.69               & 9.13                & 9.09               & 76.5                  & 61.6                  & 67.2                  & 68.1                 & 98.2                                                                                       \\
\multicolumn{1}{|l}{}                                                                                  & Compositor   & 5.01          & 33.9          & 6.34         & 5.02        & 5.01                             & 7.51               & 9.2                & 9.89                & 10.19              & 54.5                  & 52.4                  & 54.9                  & 57.5                 & 80.3                                                                                       \\
\multicolumn{1}{|l}{}                                                                                  & Híbrido      & 7.14          & 34.7          & 16.7         & 22.8        & 11.04                            & 7.35               & 9.76               & 10.45               & 10.24              & 49.6                  & 48.2                  & 50.5                  & 57                   & 76.3                                                                                       \\ \hline
\multicolumn{1}{|c}{\multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Composição\\ condicional\end{tabular}}} & Improviso    & 9.6           & 8.47          & 18.3         & 15.7        & 8.44                             & 7.05               & 8.79               & 7.12                & 9.23               & 78.9                  & 63.8                  & 64.44                 & 67.3                 & 96.6                                                                                       \\
\multicolumn{1}{|c}{}                                                                                  & Compositor   & 5.65          & 25.7          & 6.97         & 25.1        & 6.49                             & 7.51               & 9.57               & 6.49                & 10.1               & 58.5                  & 53.4                  & 70.62                 & 64                   & 89.5                                                                                       \\
\multicolumn{1}{|c}{}                                                                                  & Híbrido      & 7.09          & 9.53          & 15.3         & 28.5        & 9.05                             & 7.86               & 9.43               & 8.33                & 9.32               & 48.3                  & 60.6                  & 72.27                 & 72.1                 & 76.8                                                                                       \\ \hline
\end{tabular*}
1
  • Which document class do you employ? Which font, and which font size do you use? How wide is the text block? Which packages need to be loaded to make your code snippet compilable? – Mico Nov 25 '19 at 21:38
3

It is just to move a \\ one place in the last column. However, I will suggest that you set the tabular without nested tabulars using tabularx and booktabs. See example 2:

Example 1

enter image description here

\documentclass[paper=landscape, DIV=15]{scrartcl}
\usepackage{array, multirow}


\begin{document}


\centering

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ll|lllll|llll|llll|l|}
\cline{3-16}

&
&\multicolumn{5}{c|}{\begin{tabular}[c]{@{}c@{}}Compassos com \\ pausas (CV; \%)\end{tabular}}
&\multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Notas Usadas\\  (NCN)\end{tabular}}
&\multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Qualidade das \\ Notas (NQ; \%)\end{tabular}}
&\multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Razão de \\Intervalos  RI(\%)\end{tabular}} \\
&             & S             & Pe            & V            & Pi          & C                                & S                  & V                  & Pi                  & C                  & S                     & V                     & Pi                    & C                    & Pe                                                                                         \\ \hline
\multicolumn{2}{|l|}{Dados de treinamento}                                                                            & 13.06         & 13.06         & 24.4         & 29.8        & 15.1                             & 6.71               & 8.08               & 8.28                & 8.38               & 95                    & 86.9                  & 93.4                  & 94.6                 & 93.6                                                                                       \\ \hline
\multicolumn{1}{|l}{\multirow{4}{*}{\begin{tabular}[c]{@{}l@{}}Composição\\   do zero\end{tabular}}}   & Simplificado & 97.4          & 100           & 17.5         & 5.68        & \multicolumn{1}{c|}{5.00}        & 6                  & 7.88               & 7.32                & 9.72               & 5                     & 27.8                  & 36.1                  & 31.2                 & 5                                                                                          \\
\multicolumn{1}{|l}{}                                                                                  & Improviso    & 11.59         & 7.33          & 23.3         & 27.6        & 11.1                             & 6.53               & 8.69               & 9.13                & 9.09               & 76.5                  & 61.6                  & 67.2                  & 68.1                 & 98.2                                                                                       \\
\multicolumn{1}{|l}{}                                                                                  & Compositor   & 5.01          & 33.9          & 6.34         & 5.02        & 5.01                             & 7.51               & 9.2                & 9.89                & 10.19              & 54.5                  & 52.4                  & 54.9                  & 57.5                 & 80.3                                                                                       \\
\multicolumn{1}{|l}{}                                                                                  & Híbrido      & 7.14          & 34.7          & 16.7         & 22.8        & 11.04                            & 7.35               & 9.76               & 10.45               & 10.24              & 49.6                  & 48.2                  & 50.5                  & 57                   & 76.3                                                                                       \\ \hline
\multicolumn{1}{|c}{\multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Composição\\ condicional\end{tabular}}} & Improviso    & 9.6           & 8.47          & 18.3         & 15.7        & 8.44                             & 7.05               & 8.79               & 7.12                & 9.23               & 78.9                  & 63.8                  & 64.44                 & 67.3                 & 96.6                                                                                       \\
\multicolumn{1}{|c}{}                                                                                  & Compositor   & 5.65          & 25.7          & 6.97         & 25.1        & 6.49                             & 7.51               & 9.57               & 6.49                & 10.1               & 58.5                  & 53.4                  & 70.62                 & 64                   & 89.5                                                                                       \\
\multicolumn{1}{|c}{}  & Híbrido      & 7.09          & 9.53          & 15.3         & 28.5        & 9.05                             & 7.86               & 9.43               & 8.33                & 9.32               & 48.3                  & 60.6                  & 72.27                 & 72.1                 & 76.8
\\ \hline
\end{tabular*}

\end{document}

Example 2 – tabularx and booktabs

enter image description here

\documentclass[paper=landscape, DIV=20]{scrartcl}
\usepackage{array, multirow}
\usepackage{tabularx, booktabs, siunitx, ragged2e}

\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{P}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1cm}}

\begin{document}


\begin{table}
\caption{Adaptive learning rate \emph{etc}.}
\centering\small
\begin{tabularx}{\textwidth}{@{}Ll*{13}{S[table-format=2.2]}S[table-format=2.1]@{}}
\toprule
&
&\multicolumn{5}{P{6.5}}{Compassos \linebreak com pausas (CV; \%)}
&\multicolumn{4}{P{4}}{Notas Usadas \linebreak (NCN)}
&\multicolumn{4}{P{4}}{Qualidade das Notas (NQ; \%)}
&\multicolumn{1}{P{2.6}}{Razão de Intervalos  RI(\%)} \\
\cmidrule(lr){3-7}\cmidrule(lr){8-11}\cmidrule(lr){12-15}\cmidrule(lr){16-16}

& & {$S$} & {$Pe$} & {$V$} & {$Pi$}  & {$C$}  & {$S$}  & {$V$} & {$Pi$}  & {$C$} & {$S$} & {$V$} & {$Pi$} & {$C$}  & {$Pe$}\\ 
\midrule
\multicolumn{2}{@{}l}{Dados de treinamento}  & 13.06 & 13.06 & 24.4 & 29.8  & 15.1 & 6.71 & 8.08 & 8.28  & 8.38 & 95  & 86.9  & 93.4  & 94.6 & 93.6 \\ \midrule
\multicolumn{1}{@{}X}{\multirow{4}{=}{Composição\\ do zero}} & Simplificado & 97.4  & 100 & 17.5 & 5.68  & 5.00  & 6  & 7.88 & 7.32  & 9.72 & 5 & 27.8  & 36.1  & 31.2 & 5  \\
\multicolumn{1}{@{}l}{}  & Improviso  & 11.59 & 7.33  & 23.3 & 27.6  & 11.1 & 6.53 & 8.69 & 9.13  & 9.09 & 76.5  & 61.6  & 67.2  & 68.1 & 98.2 \\
\multicolumn{1}{@{}l}{}  & Compositor & 5.01  & 33.9  & 6.34 & 5.02  & 5.01 & 7.51 & 9.2  & 9.89  & 10.19  & 54.5  & 52.4  & 54.9  & 57.5 & 80.3 \\
\multicolumn{1}{@{}l}{}  & Híbrido  & 7.14  & 34.7  & 16.7 & 22.8  & 11.04  & 7.35 & 9.76 & 10.45 & 10.24  & 49.6  & 48.2  & 50.5  & 57 & 76.3 \\ \midrule
\multicolumn{1}{@{}X}{\multirow{3}{=}{Composição\\ condicional}} & Improviso  & 9.6 & 8.47  & 18.3 & 15.7  & 8.44 & 7.05 & 8.79 & 7.12  & 9.23 & 78.9  & 63.8  & 64.44 & 67.3 & 96.6 \\
\multicolumn{1}{@{}l}{}  & Compositor & 5.65  & 25.7  & 6.97 & 25.1  & 6.49 & 7.51 & 9.57 & 6.49  & 10.1 & 58.5  & 53.4  & 70.62 & 64 & 89.5 \\
\multicolumn{1}{@{}l}{}  & Híbrido  & 7.09  & 9.53  & 15.3 & 28.5  & 9.05 & 7.86 & 9.43 & 8.33  & 9.32 & 48.3  & 60.6  & 72.27 & 72.1 & 76.8
\\ \bottomrule
\end{tabularx}
\end{table}

\end{document}
2

I'd like to suggest that you (a) give your table a much more open an inviting look by getting rid of all vertical lines, (b) use the line-drawing macros of the booktabs package instead of \hline and \cline, and (c) align all numbers on their (explicit or implicit) decimal markers with the help of the S column type that's provided by the siunitx package.

enter image description here

\documentclass{article}
\usepackage{multirow}
\usepackage[portuguese]{babel}
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{rotating} % for 'sidewaystable' environment
\usepackage{siunitx}  % for 'S' column type
\usepackage{booktabs}
\begin{document}

\begin{sidewaystable} % switch to landscape format
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} ll *{13}{S} S[table-format=2.1]}
\toprule
& & 
\multicolumn{5}{c}{\begin{tabular}[c]{c}Compassos com \\ pausas (CV; \%)\end{tabular}} & 
\multicolumn{4}{c}{\begin{tabular}[c]{c}Notas Usadas\\ (NCN)\end{tabular}}             & 
\multicolumn{4}{c}{\begin{tabular}[c]{c}Qualidade das \\ Notas (NQ; \%)\end{tabular}}  & 
\multicolumn{1}{c}{\begin{tabular}[c]{c}Razão de Inter-\\ valos RI (\%)\end{tabular}} \\
\cmidrule{3-7} \cmidrule{8-11} \cmidrule{12-15} \cmidrule{16-16}
& & {S} & {Pe} & {V} & {Pi} & {C} & {S} & {V} & {Pi} & {C} & {S} & {V} & {Pi} & {C} & {Pe} \\ 
\midrule
\multicolumn{2}{l}{Dados de treinamento} & 
13.06 & 13.06 & 24.4 & 29.8 & 15.1 & 6.71 & 8.08 & 8.28 & 8.38 & 95.0 & 86.9 & 93.4 & 94.6 & 93.6 \\ 
\midrule
\multirow{4}{*}{\begin{tabular}[c]{l}Composição\\ do zero\end{tabular}} 
& Simplificado & 97.4  &100.0  & 17.5  &  5.68 &  5.00 & 6.0  & 7.88 & 7.32 &  9.72 &  5.0 & 27.8 & 36.1 & 31.2 & 5.0  \\
& Improviso    & 11.59 &  7.33 & 23.3  & 27.6  & 11.1  & 6.53 & 8.69 & 9.13 &  9.09 & 76.5 & 61.6 & 67.2 & 68.1 & 98.2 \\
& Compositor   &  5.01 & 33.9  &  6.34 &  5.02 &  5.01 & 7.51 & 9.2  & 9.89 & 10.19 & 54.5 & 52.4 & 54.9 & 57.5 & 80.3 \\
& Híbrido      &  7.14 & 34.7  & 16.7  & 22.8  & 11.04 & 7.35 & 9.76 &10.45 & 10.24 & 49.6 & 48.2 & 50.5 & 57.0 & 76.3 \\ 
\midrule
\multirow{3}{*}{\begin{tabular}[c]{l}Composição\\ condicional\end{tabular}}
& Improviso & 9.6  &  8.47 & 18.3  & 15.7 & 8.44 & 7.05 & 8.79 & 7.12 &  9.23 & 78.9 & 63.8 & 64.44 & 67.3 & 96.6 \\
& Compositor& 5.65 & 25.7  &  6.97 & 25.1 & 6.49 & 7.51 & 9.57 & 6.49 & 10.1  & 58.5 & 53.4 & 70.62 & 64.0 & 89.5 \\
& Híbrido   & 7.09 &  9.53 & 15.3  & 28.5 & 9.05 & 7.86 & 9.43 & 8.33 &  9.32 & 48.3 & 60.6 & 72.27 & 72.1 & 76.8 \\ 
\bottomrule
\end{tabular*}
\end{sidewaystable}
\end{document}
2
  • 1
    Very clever combination of \tabular* and \setlength{\tabcolsept}{0pt}. You save lots of @{}. I have never seen that before! – Sveinung Nov 28 '19 at 9:13
  • @Sveinung - Many thanks for compliment! :-) Setting \setlength{\tabcolsep}{0pt} when using tabular* (along with @{\extracolsep{\fill}}) is something I figured out on my own, some time ago; it's definitely not suggested in any LaTeX tutorial I've ever come across. Not only does this save the author from having to type lots of instances of @{}, it also saves the author from having to supply left- and right-hand trimming instructions when using \cmidrule. – Mico Nov 28 '19 at 9:24

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.