0

I want table total size = page width and each column to automatically adjust so no new line. My algorithm and result and how i want it to be are all below

latex

enter image description here

\chapter*{Appendix B: Camera Calibration Data}

\begin{tabu} to \textwidth { | X[c] | X[c] | X[c] | X[c] | X[c] | X[c] | X[c] |}
  \hline
Giallo 1 &  77.261978 & 9.3193226 & 240  &  840 &   1405 &  165\\
  \hline
Giallo 2 &  77.568573 & 34.337677 & 425  &  395 &   1495 &  400\\
  \hline
Giallo 3 &  77.648048 & 57.3634   & 525  &  180 &   1650 &  775\\
  \hline
Giallo 4 &  97.427101 & 56.906445 & 1375 &  180 &   290  &  765\\
  \hline
Giallo 5 &  96.904655 & 9.5490179 & 1605 &  795 &   580  &  170\\
\hline
  \multicolumn{7}{|c|}{}\\
 \hline
Fisso 6 &   104.86995 & 0.1017158 & -    &  -   &   295  &  105\\
  \hline
Fisso 7 &   104.90186 & 13.779555 & -    &  -   &   210  &  205\\
  \hline
Fisso 8 &   88.314507 & 15.439806 & 1025 &  705 &   930  &  205\\
  \hline
Fisso 9 &   88.519508 & 54.162239 & 995  &  205 &   905  &  705\\
  \hline
Fisso 10 &  104.91088 & 54.122761 & 1725 &  200 &   -    &  -\\
  \hline
Fisso 11 &  104.91105 & 67.927704 & 1645 &  100 &   -    &  -\\
  \hline
Fisso 12 &  104.88148 & 43.205231 & 1800 &  300 &   -    &  -\\
  \hline
Fisso 13 &  99.531624 & 43.12846  & 1535 &  300 & 275    &  525\\
  \hline
Fisso 14 &  99.547058 & 24.85062  & 1650 &  520 & 400    &  300\\
  \hline
Fisso 15 &  104.88358 & 24.879362 & -    &  -   & 130    &  300\\
  \hline
\multicolumn{7}{|c|}{}\\
 \hline
Bianco 16 & 85.133896 & 3.8741865 & 780  & 925  & 1070  &   130\\
  \hline
Bianco 17 & 72.73455  & 3.8047862 & -    & -    & 1570  &   130\\
  \hline
Bianco 18 & 72.379257 & 62.353729 & 320  &  140 &   -   &   -\\
  \hline
Bianco 19 & 85.527481 & 62.000118 & 865  & 145  & 1110  &   870\\
  \hline
  \multicolumn{7}{|c|}{}\\
 \hline
Fisso 20  & 93.989212 & 34.106133 & 1290 &  400 & 635   &   400\\
  \hline
\end{tabu}
  • 2
    If you change "Bianco 16" to "Bianco~16" and the same for others, it will not be split over two lines. – Piet van Oostrum Nov 24 '16 at 17:07
  • 1
    To get more room, round your numbers according to the precision of your measurement. As the number of decimal places varies from 4 to 6, it seems this did not yet happen. – user36296 Nov 24 '16 at 17:20
  • I would prefer not to round my numbers but I still used it anyway :) Simple solution. And the solution to use ~ is really cool. – Kong Nov 24 '16 at 17:22
2

Of course I cannot judge the precision of your measurement, but I guess that it is worse than 10^{-6} [whatever units your numbers are in]. So you should anyway round the figures to a meaningful value. In return you will have enough room for the first row.

\documentclass{report}
\usepackage{tabularx}
\usepackage{siunitx}


\begin{document}    
\chapter*{Appendix B: Camera Calibration Data}
\begin{tabularx}{\linewidth}{|X|*{2}{S[table-format=3.4,round-mode=places,round-precision=4]|}*{4}{S[table-format=4.0]|}}
    \hline
    Giallo 1 &  77.261978 & 9.3193226 & 240  &  840 &   1405 &  165\\\hline
    Giallo 2 &  77.568573 & 34.337677 & 425  &  395 &   1495 &  400\\\hline
    Giallo 3 &  77.648048 & 57.3634   & 525  &  180 &   1650 &  775\\\hline
    Giallo 4 &  97.427101 & 56.906445 & 1375 &  180 &   290  &  765\\\hline
    Giallo 5 &  96.904655 & 9.5490179 & 1605 &  795 &   580  &  170\\\hline
    Fisso 6 &   104.86995 & 0.1017158 & {-}    &  {-}   &   295  &  105\\\hline
\end{tabularx}
\end{document}

enter image description here

3

Here is a complete example. Just increase the width pf the first three columns a bit:

\documentclass{report}

\usepackage{tabu}

\begin{document}
\chapter*{Appendix B: Camera Calibration Data}

\begin{tabu} to \textwidth { | X[1.5, c] | X[1.5, c]| X[1.5, c] | X[c] | X[c] | X[c] | X[c] |}
  \hline
& \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{Camera 1}  & \multicolumn{2}{c|}{Camera 2} \\ 
\hline
& \multicolumn{2}{c|}{World Coordinates} & \multicolumn{2}{c|}{Image Coordinates}  & \multicolumn{2}{c|}{Image Coordinates} \\ 
\hline
Giallo 1 &  77.261978 & 9.3193226 & 240  &  840 &   1405 &  165\\
  \hline
Giallo 2 &  77.568573 & 34.337677 & 425  &  395 &   1495 &  400\\
  \hline
Giallo 3 &  77.648048 & 57.3634   & 525  &  180 &   1650 &  775\\
  \hline
Giallo 4 &  97.427101 & 56.906445 & 1375 &  180 &   290  &  765\\
  \hline
Giallo 5 &  96.904655 & 9.5490179 & 1605 &  795 &   580  &  170\\
\hline
  \multicolumn{7}{|c|}{}\\
 \hline
Fisso 6 &   104.86995 & 0.1017158 & -    &  -   &   295  &  105\\
  \hline
Fisso 7 &   104.90186 & 13.779555 & -    &  -   &   210  &  205\\
  \hline
Fisso 8 &   88.314507 & 15.439806 & 1025 &  705 &   930  &  205\\
  \hline
Fisso 9 &   88.519508 & 54.162239 & 995  &  205 &   905  &  705\\
  \hline
Fisso 10 &  104.91088 & 54.122761 & 1725 &  200 &   -    &  -\\
  \hline
Fisso 11 &  104.91105 & 67.927704 & 1645 &  100 &   -    &  -\\
  \hline
Fisso 12 &  104.88148 & 43.205231 & 1800 &  300 &   -    &  -\\
  \hline
Fisso 13 &  99.531624 & 43.12846  & 1535 &  300 & 275    &  525\\
  \hline
Fisso 14 &  99.547058 & 24.85062  & 1650 &  520 & 400    &  300\\
  \hline
Fisso 15 &  104.88358 & 24.879362 & -    &  -   & 130    &  300\\
  \hline
\multicolumn{7}{|c|}{}\\
 \hline
Bianco 16 & 85.133896 & 3.8741865 & 780  & 925  & 1070  &   130\\
  \hline
Bianco 17 & 72.73455  & 3.8047862 & -    & -    & 1570  &   130\\
  \hline
Bianco 18 & 72.379257 & 62.353729 & 320  &  140 &   -   &   -\\
  \hline
Bianco 19 & 85.527481 & 62.000118 & 865  & 145  & 1110  &   870\\
  \hline
  \multicolumn{7}{|c|}{}\\
 \hline
Fisso 20  & 93.989212 & 34.106133 & 1290 &  400 & 635   &   400\\
  \hline
\end{tabu}
\end{document}
3

Your columns do contain diffenrent amounts of numbers. So you should not use the same width for any column. Just stretch the first one, if you really want to get the maximum width here:

% arara: pdflatex

\documentclass{report}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}    
\chapter*{Appendix B: Camera Calibration Data}
\begin{tabularx}{\linewidth}{%
        X
        S[table-format=3.6]
        S[table-format=2.7]
        S[table-format=4.0]
        S[table-format=3.0]
        S[table-format=4.0]
        S[table-format=3.0]
    }
    \toprule
    Giallo 1 &  77.261978 & 9.3193226 & 240  &  840 &   1405 &  165\\
    Giallo 2 &  77.568573 & 34.337677 & 425  &  395 &   1495 &  400\\
    Giallo 3 &  77.648048 & 57.3634   & 525  &  180 &   1650 &  775\\
    Giallo 4 &  97.427101 & 56.906445 & 1375 &  180 &   290  &  765\\
    Giallo 5 &  96.904655 & 9.5490179 & 1605 &  795 &   580  &  170\\
    \addlinespace
    Fisso 6 &   104.86995 & 0.1017158 & {-}    &  {-}   &   295  &  105\\
    Fisso 7 &   104.90186 & 13.779555 & {-}    &  {-}   &   210  &  205\\
    Fisso 8 &   88.314507 & 15.439806 & 1025 &  705 &   930  &  205\\
    Fisso 9 &   88.519508 & 54.162239 & 995  &  205 &   905  &  705\\
    Fisso 10 &  104.91088 & 54.122761 & 1725 &  200 &   {-}    &  {-}\\
    Fisso 11 &  104.91105 & 67.927704 & 1645 &  100 &   {-}    &  {-}\\
    Fisso 12 &  104.88148 & 43.205231 & 1800 &  300 &   {-}    &  {-}\\
    Fisso 13 &  99.531624 & 43.12846  & 1535 &  300 & 275    &  525\\
    Fisso 14 &  99.547058 & 24.85062  & 1650 &  520 & 400    &  300\\
    Fisso 15 &  104.88358 & 24.879362 & {-}    &  {-}   & 130    &  300\\
    \addlinespace
    Bianco~16 & 85.133896 & 3.8741865 & 780  & 925  & 1070  &   130\\
    Bianco~17 & 72.73455  & 3.8047862 & {-}    & {-}    & 1570  &   130\\
    Bianco~18 & 72.379257 & 62.353729 & 320  &  140 &   {-}   &   {-}\\
    Bianco~19 & 85.527481 & 62.000118 & 865  & 145  & 1110  &   870\\
    \addlinespace
    Fisso 20  & 93.989212 & 34.106133 & 1290 &  400 & 635   &   400\\
    \bottomrule
\end{tabularx}
\end{document}

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.