I'm trying to write a table in LaTeX using multirows and multicolumns right in the header. I managed to get it just like I want it with this code (which I compiled easily in overleaf):

\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage[margin=3cm]{geometry}% http://ctan.org/pkg/geometry

\setlength\extrarowheight{2pt}%%precisei definir isso para dar meis espaço para a bottom rule da tabela
    \multirow{2}{*}{\parbox{0.15\linewidth}{\centering Dimensão da Teoria do Fluxo}} \multirow{2}{*}{\parbox{0.15\linewidth}{\centering Componente do Framework}} & \multicolumn{3}{c}{\parbox{0.7\linewidth}{\centering Heurísticas}} \\ %%defini parboxes para setar as dimensões de cada coluna de acordo com a margem do texto.
     & &
    \parbox{0.1\linewidth}{\centering N} &
    \parbox{0.3\linewidth}{\centering Descrição detalhada} & 
    \parbox{0.3\linewidth}{\centering Referências CALL} \\

It gives me the following table:

my table

However, as soon as I enter some lines, the table gets stretched and it's not entering data according to my 5-cell rule, I don't know why!

enter image description here

  • 1
    Welcome to TeX.SE! In the future, you can copy and paste code into your question, I have copied it from dropbox into your question (if the edit is approved). There is a symbol that looks like {}, this formats code in the question, hope someone can help!
    – JamesT
    Commented Feb 17, 2023 at 17:56
  • 2
    Please provide some more information as to what "as soon as I enter some lines" entails.
    – Mico
    Commented Feb 17, 2023 at 18:40

1 Answer 1

  • It is not entirely clear how your table should look, so proposed possible solution is based on guessing what you after
  • I would not use \parboxes for text in table cells. Instead of it I would rather prescribe of column widths
  • Splitting cells in the first columns lead to troubles. Better is divide column into two columns in where is needed, merge adjacent columns into \multicolumn cell.
  • In MWE below is assumed that you like to have multi column cells only at first two column, so for this columns are defined special new command.
  • For more sophisticate table structure can be managed by use Tabularray package. However, for its use I need more information about your table (so please extend your table code to more rows (with some dummy text),
\usepackage[margin=3cm]{geometry}% http://ctan.org/pkg/geometry
%---------------- show page layout. don't use in a real document!


\setlength\extrarowheight{2pt}%%precisei definir isso para dar meis espaço para a bottom rule da tabela
\begin{tabularx}{\textwidth}{@{}    C{0.15} C{0.15}
                                    C{0.3}  C{0.3}
\multirow{2}{=}{Dimensão da Teoria do Fluxo}
    &   \multirow{2}{=}{Componente do Framework}
        & \multicolumn{3}{c}{Heurísticas}           \\
    &   &   N
            &   Descrição detalhada
                &       Referências CALL            \\
\mcxx{some quite long text over three columns}
            &   &                                   \\
A   & B & C & D & E                                 \\

enter image description here

(red lines indicate document pages layouts)

  • my table isn't just large, it's really big too. I migrated to longtablearray(longtablr) a while ago (I developed my table a bit more: tex.stackexchange.com/questions/675637/…), but I can't make it so that the table gets large (so it occupies the whole paper width), AND also gets in 2 pages. do you know how? Commented Feb 17, 2023 at 22:44
  • @FabioPhillip, it seems that question in your link is follows up question where you already use codes from my answer on this question. If so, make this question solved by accepting it (click on the check mark at top left side of answer). I would try to answer on newer question.
    – Zarko
    Commented Feb 18, 2023 at 7:36

You must log in to answer this question.

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