3

I am having some troubles with a multicolumn table. The table should look like this sample inside a word doc: enter image description here

But the template that i am using is in LaTeX and when i compile the code that i made i receive this: enter image description here

This is the code, I think the problem is in the centralization.

\PassOptionsToPackage{english, main = brazilian}{babel}%% Multilíngue
\PassOptionsToPackage{hyperfootnotes = false}{hyperref}%% Hipertexto extendido

%% Classe de documento e opções \documentclass[%% Opções: [*] comente para remover; [>] passada para pacotes article,%% Tipo de documento: article, book, report, etc. [>] a4paper,%% Tamanho de papel: a4paper, letterpaper, etc. [>] 11pt,%% Tamanho de fonte: 10pt, 11pt, 12pt, etc. [>] fleqn,%% Alinhamento de equações à esquerda (comente para centralizado) [>] oneside,%% Impressão: oneside (anverso) ou twoside (anverso e verso) [>] % twocolumn,%% Texto em duas colunas (comente para uma coluna) [>] chapter = TITLE,%% Títulos de capítulos em maiúsculas [*] section = TITLE,%% Títulos de seções (secundárias) em maiúsculas [*] ]{abntex2}

\usepackage{lipsum} \usepackage{changepage} \usepackage{graphicx} \usepackage{array} \newcolumntype{N}{>{\centering\arraybackslash}m{.5in}} \newcolumntype{G}{>{\centering\arraybackslash}m{2in}}

\newcommand*{\boldsymbol}[1]{#1}

\begin{document}

\begin{table}[!htb] \centering \caption{Parâmetros obtidos para o ajuste utilizando o modelo de Langmuir.}% \label{tab:resul} \begin{tabular}{c c| c c} \hline \multicolumn{4}{c}{Modelo de Langmuir}: \begin{minipage}{5.5cm}{\begin{equation}\label{eq:Uxy} \frac{\Qmax\ K_L Ceq}{\1\ +K_L Ceq} = Qe \end{equation}} \end{minipage} \ \cline{1-4} \centering \multicolumn{1}{c}{\textbf{HDL Calc}} & \multicolumn{3}{c}{\textbf{HDL SDS Calc}}\ \hline \multicolumn{1}{c}{Qmax} & K(L/mg) & Qmax(mg/g) & K(L/mg)\ \hline \multicolumn{1}{c}{690,6} & 0,011 & 132,3 & 0,136\ \hline \end{tabular} \fonte{Autoria própria (2021).} \end{table}

\end{document}

  • Welcome to TeX.SX! Please make your code compilable by adding the documentclass. Also, how is \fonte defined? – leandriis Sep 05 '21 at 17:33
  • You may want to replace \centering \multicolumn{1}{c}{\textbf{HDL Calc}} & \multicolumn{3}{c}{\textbf{HDL SDS Calc}}\\ with \multicolumn{2}{c}{\textbf{HDL Calc}} & \multicolumn{2}{c}{\textbf{HDL SDS Calc}}\\ to get closer to the expected output. – leandriis Sep 05 '21 at 17:35

3 Answers3

2

With tabularray package. MWE below reproduce you first image which you like to reproduce by using LaTeX. Since I haven't your document class, in MWE is used standard article, however table code will works in your ddocument class too:

\documentclass[twocolummn]{article}
\usepackage[skip=1ex]{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx} 
\sisetup{per-mode=symbol}

\begin{document} \begin{table*}[htb] \centering \caption{Parâmetros obtidos para o ajuste utilizando o modelo de Langmuir.}% \label{tab:resul}

\begin{tblr}{hlines,vline{3}=solid, colspec={*{4}{X[1,c]}}, row{2} = {font=\bfseries} } \SetCell[c=4]{c} Modelo de Langmuir: $\displaystyle \frac{Q_{\max} K_L C_{\mathrm{eq}}} {1 + K_L C_\mathrm{eq}} = Q_\mathrm{e}$
& & & \ \SetCell[c=2]{c} HDL Calc
& & \SetCell[c=2]{c} HDL SDS Calc & \ $Q_{\max}$ & K(\unit{\L\per\mg}) & $Q_{\max}$ (\unit{\mg\per\g}) & K(\unit{\L\per\mg}) \ 690,6 & 0,011 & 132,3 & 0,136 \ \end{tblr}

Fonte: {Autoria própria (2021).} \end{table*}

\end{document}

enter image description here

F. Pantigny
  • 40,250
Zarko
  • 296,517
1

The following should get you closer to the expected output:

enter image description here

\PassOptionsToPackage{english, main = brazilian}{babel}%% Multilíngue
\PassOptionsToPackage{hyperfootnotes = false}{hyperref}%% Hipertexto extendido

%% Classe de documento e opções \documentclass[%% Opções: [*] comente para remover; [>] passada para pacotes article,%% Tipo de documento: article, book, report, etc. [>] a4paper,%% Tamanho de papel: a4paper, letterpaper, etc. [>] 11pt,%% Tamanho de fonte: 10pt, 11pt, 12pt, etc. [>] fleqn,%% Alinhamento de equações à esquerda (comente para centralizado) [>] oneside,%% Impressão: oneside (anverso) ou twoside (anverso e verso) [>] % twocolumn,%% Texto em duas colunas (comente para uma coluna) [>] chapter = TITLE,%% Títulos de capítulos em maiúsculas [*] section = TITLE,%% Títulos de seções (secundárias) em maiúsculas [*] ]{abntex2}

\usepackage{array} \usepackage{siunitx} \sisetup{per-mode=symbol} \usepackage[column=0]{cellspace} \setlength{\cellspacetoplimit}{4pt} \setlength{\cellspacebottomlimit}{\cellspacetoplimit} \begin{document}

\begin{table}[!htb] \centering \caption{Parâmetros obtidos para o ajuste utilizando o modelo de Langmuir.}% \label{tab:resul} \begin{tabular}{{2}{0{wc{2.5cm}}}|{2}{0{wc{2.5cm}}}} \hline \multicolumn{4}{0c}{Modelo de Langmuir: \begin{minipage}{5.5cm}{\begin{equation}\label{eq:Uxy} \frac{\Qmax\ K_L Ceq}{\1\ +K_L Ceq} = Qe \end{equation}} \end{minipage}} \ \cline{1-4} \multicolumn{2}{0c|}{\textbf{HDL Calc}} & \multicolumn{2}{0c}{\textbf{HDL SDS Calc}}\ \hline Qmax & K(\unit{\L\per\mg}) & Qmax(\unit{\mg\per\g}) & K(\unit{\L\per\mg})\ \hline 690,6 & 0,011 & 132,3 & 0,136\ \hline \end{tabular} \fonte{Autoria própria (2021).} \end{table}

\end{document}

leandriis
  • 62,593
  • I am sorry about no putting the documentclass before. Thank you so much for the help, It is perfect! I am going to try to understand better this type of code! – João Zago Sep 05 '21 at 17:49
1

With {NiceTabular} of nicematrix.

% -*- coding: utf-8 ; -*-
\PassOptionsToPackage{english, main = brazilian}{babel}%% Multilíngue
\PassOptionsToPackage{hyperfootnotes = false}{hyperref}%% Hipertexto extendido

%% Classe de documento e opções \documentclass[%% Opções: [*] comente para remover; [>] passada para pacotes article,%% Tipo de documento: article, book, report, etc. [>] a4paper,%% Tamanho de papel: a4paper, letterpaper, etc. [>] 11pt,%% Tamanho de fonte: 10pt, 11pt, 12pt, etc. [>] fleqn,%% Alinhamento de equações à esquerda (comente para centralizado) [>] oneside,%% Impressão: oneside (anverso) ou twoside (anverso e verso) [>] % twocolumn,%% Texto em duas colunas (comente para uma coluna) [>] chapter = TITLE,%% Títulos de capítulos em maiúsculas [*] section = TITLE,%% Títulos de seções (secundárias) em maiúsculas [*] ]{abntex2}

\usepackage{siunitx} \sisetup{per-mode=symbol}

\usepackage{nicematrix,tikz}

\begin{document}

\begin{table}[!htb] \centering \caption{Parâmetros obtidos para o ajuste utilizando o modelo de Langmuir.}% \label{tab:resul} \begin{NiceTabular}{cccc}[columns-width=25mm,cell-space-limits=4pt] \hline \Block{1-4}{Modelo de Langmuir: \begin{minipage}{5.5cm}{\begin{equation}\label{eq:Uxy} \frac{Q_{\text{max}}\ K_L C_{\text{eq}}}{\1\ +K_L C_{\text{eq}}} = Q_{\text{e}} \end{equation}} \end{minipage}} \ \hline \RowStyle{\bfseries} \Block{1-2}{HDL Calc} && \Block{1-2}{HDL SDS Calc}\ \hline $Q_{\text{max}}$ & $K$(\unit{\L\per\mg}) & $Q_{\text{max}}$(\unit{\mg\per\g}) & $K$(\unit{\L\per\mg})\ \hline 690,6 & 0,011 & 132,3 & 0,136\ \hline \CodeAfter \tikz \draw (2-|3) -- (last-|3) ; \end{NiceTabular} \fonte{Autoria própria (2021).} \end{table}

\end{document}

Output of the above code

F. Pantigny
  • 40,250