0

This is what I want!

enter image description here

But my code doesn't work, it appears like this

enter image description here

    \documentclass{article}
    \usepackage[margin=1in]{geometry}
    \usepackage[spanish,es-tabla]{babel} % espanol
    \decimalpoint
    \usepackage[utf8]{inputenc}
    \usepackage{graphicx} % graficos

    \usepackage{amsmath}
    \usepackage{listings}

    \usepackage{tikz} %era para hacer los grafos pero no investigué mucho asi que lo hice con word
    \usetikzlibrary{arrows}

    %Header an Footer Stuff

    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyfoot{}
    \fancyfoot[R]{ \thepage\ }


    %Hyperlink
    \usepackage{varioref}
    \usepackage{hyperref}
    \usepackage{cleveref}
    \hypersetup{colorlinks=false}
    \hypersetup{pdfborder={0 0 0}}


    \begin{document}

 \begin{table}[htbp]
        \caption{Valores optimos Ejercicio 2}   
            \begin{tabular}{| l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l |}
            \hline
             $x_{ij}$ & 1-2 & 1-3 & 1-5 & 2-3 & 2-4 & 2-8 & 3-4 & 3-5 & 4-7 & 4-8 & 5-6 & 5-9\\
            \hline
             Valor & 30 & 15 & 14 & 7 & 7 & 16 & 12 & 10 & 7 & 12\\
            \hline
            \end{tabular}\hspace{0pt}%
            \begin{tabular}{l l | l | l | l | l | l | l | l |}
            \hline
             2-4 & 2-8 & 3-4 & 3-5 & 4-7 & 4-8 & 5-6 & 5-9\\
            \hline
            1111 & 8 & 5 & 11 & 12 & 28 & 19 & 0\\
            \hline
            \end{tabular}\hspace{0pt}%
        \label{tab:vo-ej2}
    \end{table}

    \end{document}
8
  • your second code fragment with ... code is not useful for anyone debugging your issue, please edit it so that it generates the output that you show, Nov 26, 2018 at 16:52
  • however you are only allowing a line break in one place and you have used geometry package to change the page width, so you appear to need to break at a different column. Nov 26, 2018 at 16:54
  • remove those \hspace{0pt}%s amd do a line break instead. The table will be set as in your first example then.
    – LaRiFaRi
    Nov 26, 2018 at 16:55
  • how do I add a line break ? @LaRiFaRi Nov 26, 2018 at 18:22
  • @DavidCarlisle I didn't added my code bc it's way long and I just have trouble with that piece of code that I added Nov 26, 2018 at 18:24

1 Answer 1

2

If you want that someone reads and understands your table, you might want to redesign it. What do you think about:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[spanish]{babel}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{table}
    \centering
    \caption{Valores óptimos Ejercicio 2}\label{tab:voed} 
    \begin{tabular}{c S[table-format=2.0]}
        \toprule
        $x_{ij}$ & {Valor} \\
        \midrule
         1-2 & 30 \\
         1-3 & 15 \\
         1-5 & 14 \\
         $\vdots$ & {$\vdots$} \\
         4-8 & 12 \\
         \bottomrule
    \end{tabular}\qquad
    \begin{tabular}{c S[table-format=4.0]}
        \toprule
        $x_{ij}$ & {Valor} \\
        \midrule
         5-6 &  \\
         5-9 &  \\
         2-4 & 1111 \\
         $\vdots$ & {$\vdots$} \\
         5-9 & 0 \\
         \bottomrule
    \end{tabular}
\end{table}
\end{document}

enter image description here

2
  • @LaRiFRi {c S[table-format=4.0]} those commands belong to ssiunitx ? what does c and S do ? I figured that table-format is to define how large horizontally is my table but I don't get the other ones.. I'm new using latex haha thanks in advance Nov 26, 2018 at 18:32
  • @EmiliOrtega the c is standard for centered. The S belongs to siunitx. The table-format=4.0 is telling the column to expect numbers with 4 digits before the comma and 0 after it. You are right, this fits the horizontal width.
    – LaRiFaRi
    Nov 27, 2018 at 10:21

You must log in to answer this question.

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