4

I have a problem with my table. Here's my code:

\documentclass{article}
\usepackage{eurosym}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage{subfigure}
\usepackage{vmargin}
\usepackage{caption}
\usepackage{amsmath}


\begin{document}
    \title{\empty}
    \author{\empty }
    \date{\empty}


    \maketitle


    \begin{table}[h!]
        \begin{center}
            \begin{tabular}{l|l}
                \parbox{0.4\textwidth}{sudo ifconfig serviciosB down \\
                    sudo ifconfig serviciosA \\ 172.24.1.1/24 \\
                    sudo route add -net 172.24.2.0/24 gw 172.24.1.222 }             
                    & \parbox{0.4\textwidth}{sudo ifconfig serviciosA down 
                    \\
                    sudo ifconfig serviciosB \\ 172.24.2.1/24 \\
                    sudo route add -net 172.24.1.0/24 gw 172.24.2.222}   \\  
                    \hline
                    \parbox{0.4\textwidth}{sudo ifconfig serviciosB down \\
                    sudo ifconfig serviciosA \\ 172.24.1.2/24 \\
                    sudo route add -net 172.24.2.0/24 gw 172.24.1.222} & 
                    \parbox{0.4\textwidth}{sudo ifconfig serviciosA down \\
                    sudo ifconfig serviciosB \\ 172.24.2.2/24 \\
                    sudo route add -net 172.24.1.0/24 gw 172.24.2.222} \\
            \end{tabular}
        \end{center}
    \end{table}

\end{document}

The result of that table is this one:

Table

However, I'd like to increase the space between the text and the horizontal line of the middle of the table.

I hope someone can help me. Thank you for your responses.

1

1 Answer 1

7

You could use the appropriate p{...} column type, instead of putting parboxes in cells.

I created a new column type L which is ragged right but, of course, you can use p{...} directly, if you don't want the ragging.

I also redefined \arraystretch to have a bit more space.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{array}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{.4\linewidth}}
\renewcommand{\arraystretch}{1.2}
\begin{document}
    \begin{table}[h!]
        \begin{center}
            \begin{tabular}{L|L}
               sudo ifconfig serviciosB down\newline 
               sudo ifconfig serviciosA \newline 172.24.1.1/24 \newline
                    sudo route add -net 172.24.2.0/24 gw 172.24.1.222
                    & sudo ifconfig serviciosA down 
                    \newline
                    sudo ifconfig serviciosB \newline 172.24.2.1/24 \newline
                    sudo route add -net 172.24.1.0/24 gw 172.24.2.222\\  
                    \hline
                   sudo ifconfig serviciosB down \newline
                    sudo ifconfig serviciosA \newline 172.24.1.2/24 \newline
                    sudo route add -net 172.24.2.0/24 gw 172.24.1.222 & 
                   sudo ifconfig serviciosA down \newline
                    sudo ifconfig serviciosB \newline 172.24.2.2/24 \newline
                    sudo route add -net 172.24.1.0/24 gw 172.24.2.222 \\
            \end{tabular}
        \end{center}
    \end{table}

\end{document}

enter image description here

2
  • Thank you so much, but I'd apreciate if you could give me a link or a page where I can learn to redefine types of columns to be able to do that in another occasion.
    – Josemi
    Dec 22, 2018 at 10:35
  • @Josemi You're welcome and thank you for accepting my answer! You could look at array package documentation ctan.org/pkg/array and see also here: tex.stackexchange.com/questions/11/…. And feel free tp ask a question whenever you got a problem you can't solve by yourself!
    – CarLaTeX
    Dec 22, 2018 at 10:50

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.