Problema centrare la tabella rispetto al documento

  • Creatore
    Topic
  • #89282
    Up
    0
    Down
    ::


    Buongiorno a tutti.
    Devo centrare questa tabella nel mio documento; dopo ripetuti tentativi e centinaia di pagine e blog letti, non riesco a giungere al risultato insperato e la tabella non risulta centrata.
    Vi allego il codice sia con l’ambiente table sia con l’ambiente tabular.
    Con table:

    `\begin{table}[h]
    \centering
    \renewcommand\arraystretch{0.5}
    \begin{tabular}{lcccc}
    \toprule
    \textbf{Course Name} & \textbf{Credit Hours} & \textbf{Italian Grade} & \textbf{US Grade} & \textbf{English Grade} \\
    \midrule
    Advanced Financial Accounting & 5 & 28/30 & A & 0.65 \\
    Advanced Microeconomics & 5 & 28/30 & A & 0.65 \\
    Applied Econometrics & 8 & 29/30 & A & 0.67 \\
    Applied Statistics For Finance & 6 & 30/30 & A & 0.73 \\
    Corporate Finance & 8 & 29/30 & A & 0.67 \\
    Derivative Securities Pricing & 8 & 25/30 & B & 0.57 \\
    Foreign Language (Spanish) & 4 & 30/30 & A & 0.73 \\
    Principles of Financial Regulation & 10 & 28/30 & A & 0.65 \\
    Quantitative Methods For Finance & 8 & 27/30 & A & 0.63 \\\hline
    \textbf{Academic Average} & & \textbf{28.07} & \textbf{3.87} & \textbf{0.66}\\\hline
    \bottomrule
    \end{tabular}
    \end{table}`

    con tabular:

    `\begin{center}
    \renewcommand\arraystretch{0.5}
    \begin{tabular}{lcccc}
    \toprule
    \textbf{Course Name} & \textbf{Credit Hours} & \textbf{Italian Grade} & \textbf{US Grade} & \textbf{English Grade} \\
    \midrule
    Advanced Financial Accounting & 5 & 28/30 & A & 0.65 \\
    Advanced Microeconomics & 5 & 28/30 & A & 0.65 \\
    Applied Econometrics & 8 & 29/30 & A & 0.67 \\
    Applied Statistics For Finance & 6 & 30/30 & A & 0.73 \\
    Corporate Finance & 8 & 29/30 & A & 0.67 \\
    Derivative Securities Pricing & 8 & 25/30 & B & 0.57 \\
    Foreign Language (Spanish) & 4 & 30/30 & A & 0.73 \\
    Principles of Financial Regulation & 10 & 28/30 & A & 0.65 \\
    Quantitative Methods For Finance & 8 & 27/30 & A & 0.63 \\\hline
    \textbf{Academic Average} & & \textbf{28.07} & \textbf{3.87} & \textbf{0.66}\\\hline
    \bottomrule
    \end{tabular}
    \end{center}`

    Vi ringrazio per il vostro aiuto.
    Matteo

Visualizzazione 2 filoni di risposte
  • Autore
    Risposte
    • #89283
      Up
      0
      Down
      ::


      La tabella è centrata, ma essendo più larga della gabbia del testo non vedi la centratura.
      Cerca di renderla più stretta. Centrarla rispetto alla gabbia si può comunque, ma non è una buona soluzione (in generale).
      Puoi rendertene conto racchiudendo l’ambiente tabular in:
      `\makebox[0pt]{}`

      Ciao
      Ivan

    • #89284
      Up
      0
      Down
      ::


      Con la gabbia usuale in un documento article su A4 ottengo il messaggio
      `Overfull \hbox (123.25862pt too wide)`
      La tua tabella sfora di oltre quattro centimetri e non ci sono santi. Con
      `\documentclass[a4paper]{article}
      \usepackage{booktabs}
      \begin{document}
      \begin{center}
      \begin{tabular}{lcccc}
      \toprule
      \textbf{Course Name} & \textbf{Credit} & \textbf{Italian} & \textbf{US} & \textbf{English} \\
      & \textbf{Hours} & \textbf{Grade} & \textbf{Grade} & \textbf{Grade} \\
      \midrule
      Advanced Financial Accounting & 5 & 28/30 & A & 0.65 \\
      Advanced Microeconomics & 5 & 28/30 & A & 0.65 \\
      Applied Econometrics & 8 & 29/30 & A & 0.67 \\
      Applied Statistics For Finance & 6 & 30/30 & A & 0.73 \\
      Corporate Finance & 8 & 29/30 & A & 0.67 \\
      Derivative Securities Pricing & 8 & 25/30 & B & 0.57 \\
      Foreign Language (Spanish) & 4 & 30/30 & A & 0.73 \\
      Principles of Financial Regulation & 10 & 28/30 & A & 0.65 \\
      Quantitative Methods For Finance & 8 & 27/30 & A & 0.63 \\
      \midrule
      \textbf{Academic Average} & & \textbf{28.07} & \textbf{3.87} & \textbf{0.66}\\
      \bottomrule
      \end{tabular}
      \end{center}
      \end{document}`
      lo sforamento è di soli 0.22pt, almeno con questa impostazione, e non è un grave problema; inoltre dipende dalle tue impostazioni.

      Alcune note.

      (1) [tt]\arraystretch[/tt] definito a 0.5 produce un risultato orrendo.

      (2) Usa solo i filetti di booktabs e mai doppi.

      (3) Se intendi usare [tt]table[/tt] non dare la sola opzione [tt][h][/tt], perché significa andare in cerca di guai; meglio [tt][htp][/tt]. In questo caso la didascalia è obbligatoria.

      Ciao
      Enrico

    • #89285
      Up
      0
      Down
      ::


      Grazie Mille sia ad Enrico che ad Ivan.
      Ora la tabella è presentabile….!

      Grazie dell’aiuto ragazzi, buona giornata!

      Matteo

Visualizzazione 2 filoni di risposte
  • Devi essere connesso per rispondere a questo topic.

Go to top