particolare tabella con alternate multirow

  • Creatore
    Topic
  • #24599
    Up
    0
    Down
    ::


    Salve a tutti.

    Stavo cercando di creare una tabella con alcune linee multirow e altre no.
    la struttura sarebbe la seguente:

    – – – – – D – H
    A B C E G I
    – – – – – F – L
    diciamo che dopo alcuni tentativi ci sono riuscito, ma a parer mio non nel
    modo migliore. Visto che più uno conosce meno problemi avrà in
    futuro, volevo sapere se si poteva rendere più “pulita”.
    Ecco il codice:
    `
    \begin{table}[ht]
    \centerline{
    \begin{tabular}{l c c c c c c}
    \toprule
    & $N_x$ & $N_y$ & $N_z$
    & $\Delta_x$ & $\Delta_y$ & $\Delta_z$\\
    \toprule
    \multirow{3}*{Case I} & \multirow{3}*{$230$} & \multirow{3}*{$32$} & \multirow{3}*{$190$} & SF$^*$ $1.08$ & \multirow{3}*{$0.09375D$} & SF$^*$ $1.08$\\
    & & & & $0.0102D$ & & $0.0102D$\\
    & & & & SF$^*$ $1.08$ & & SF$^*$ $1.08$\\
    \midrule
    \multirow{3}*{Case II} & \multirow{3}*{$260$} & \multirow{3}*{$32$} & \multirow{3}*{$170$} & SF$^*$ $1.12$ & \multirow{3}*{$0.09375D$} & SF* $1.12$\\
    & & & & $0.0102D$ & & $0.0102D$\\
    & & & & SF$^*$ $1.02$ & & SF$^*$ $1.02$\\
    \bottomrule
    \end{tabular}
    }
    \caption[Grid parameters of cylinder flow computations]{Grid parameters of cylinder flow computations. Parameter are:
    $N_i$ the number of cell along the $i$ direction, $\Delta_i$ the cell size along the $i$ direction. $^*$: stretching
    factor for that chunck of the domain}
    \label{table_resume_grids}
    \end{table}
    `
    Grazie mille in anticipo.

    Stefano

Visualizzazione 1 filone di risposte
  • Autore
    Risposte
    • #24600
      Up
      0
      Down
      ::

      Salve a tutti.

      Stavo cercando di creare una tabella con alcune linee multirow e altre no.
      la struttura sarebbe la seguente:

      – – – – – D – H
      A B C E G I
      – – – – – F – L
      diciamo che dopo alcuni tentativi ci sono riuscito, ma a parer mio non nel
      modo migliore. Visto che più uno conosce meno problemi avrà in
      futuro, volevo sapere se si poteva rendere più “pulita”.
      Ecco il codice:
      `
      \begin{table}[ht]
      \centerline{
      \begin{tabular}{l c c c c c c}
      \toprule
      & $N_x$ & $N_y$ & $N_z$ &
      $\Delta_x$ & $\Delta_y$ & $\Delta_z$\\
      \toprule
      \multirow{3}*{Case I} & \multirow{3}*{$230$} & \multirow{3}*{$32$} & \multirow{3}*{$190$} & SF$^*$ $1.08$ & \multirow{3}*{$0.09375D$} & SF$^*$ $1.08$\\
      & & & & $0.0102D$ & & $0.0102D$\\
      & & & & SF$^*$ $1.08$ & & SF$^*$ $1.08$\\
      \midrule
      \multirow{3}*{Case II} & \multirow{3}*{$260$} & \multirow{3}*{$32$} & \multirow{3}*{$170$} & SF$^*$ $1.12$ & \multirow{3}*{$0.09375D$} & SF* $1.12$\\
      & & & & $0.0102D$ & & $0.0102D$\\
      & & & & SF$^*$ $1.02$ & & SF$^*$ $1.02$\\
      \bottomrule
      \end{tabular}
      }
      \caption[Grid parameters of cylinder flow computations]{Grid parameters of cylinder flow computations. Parameter are:
      $N_i$ the number of cell along the $i$ direction, $\Delta_i$ the cell size along the $i$ direction. $^*$: stretching
      factor for that chunck of the domain}
      \label{table_resume_grids}
      \end{table}
      `

      Intanto quel \centerline{…} va tolto e sostituito con un semplice \centering.

      Il modo più pulito è di non usare multirow, ma semplicemente una tabella dentro la tabella per le celle che contengono più elementi in verticale:
      ` \begin{tabular}{l c c c c c c}
      \toprule
      & $N_x$ & $N_y$ & $N_z$ & $\Delta_x$ & $\Delta_y$ & $\Delta_z$\\
      \toprule
      Case I & $230$ & $32$ & $190$ &
      \begin{tabular}{@{}c@{}}
      SF$^*$ $1.08$\\
      $0.0102D$\\
      SF$^*$ $1.08$
      \end{tabular} & $0.09375D$ &
      \begin{tabular}{@{}c@{}}
      SF$^*$ $1.08$\\
      $0.0102D$\\
      SF$^*$ $1.08$
      \end{tabular}\\

      \bottomrule
      \end{tabular}`
      Se carichi il pacchetto array, puoi abbreviare di molto il codice, togliendo tutti i $ dalla tabella, se sostituisci l’argomento del tabular esterno con
      `{l *{3}{>{$}c<{$}} c >{$}c<{$} c}` e quello dei tabular interni con `{@{}>{$}c<{$}@{}}` Ciao Enrico

    • #24601
      Up
      0
      Down
      ::


      Questa è magia!!! 😀

      Ho veramente ancora tanto (troppo) da imparare…

      Grazie ancora Enrico. Mi dispiaceva avviare questo post, soprattutto per non disturbarti ancora, comunque grazie ancora!!!
      Mi sa che vado veramente a chiedere di fare una statua in tuo onore, in centro a Bruxelles.

      Ciao

      Stefano

Visualizzazione 1 filone di risposte
  • Devi essere connesso per rispondere a questo topic.

Go to top