1

I am trying to keep two tables in parallel in latex for the LNCS format. Also tried doing as mentioned in this answer. But I am getting really badly formatted tables. The code and the results are as follows:

\begin{table}
\parbox{.4\linewidth}{
\centering
\begin{tabular}{l}
\hline
\textbf{Eliminate($D_s$):}\\
\textbf{Input:} ~Subspace $D_s \subseteq D$\\
\textbf{Output:} None\\
\hline
1.~\textbf{if} $D_s$ is not marked as \textbf{\textit{eliminated}} \textbf{then}\\
2.~~~~~Mark $D_s$ as \textbf{\textit{eliminated}}\\
3.~~~~~\textbf{for each} $D'_s \subset D_s$ such that $|D_s|-|D'_s|=1$ \textbf{do}\\
4.~~~~~~~~~$Eliminate(D'_s)$\\
5.~~~~~\textbf{end for}\\
6.~\textbf{end if}\\
\hline
\end{tabular}
\caption{Eliminate Function}
\label{topdown_2}
}
\hfill
\parbox{.4\linewidth}{
\centering
\begin{tabular}{l}
\hline
\textbf{NonISQ($D_1$, $D_2$):}\\
\textbf{Input:} ~Subspaces $D_1, D_2 \subseteq D$\\
\textbf{Output:} None\\
\hline
1.~Let $D_s = D_1 \cup D_2$\\
2.~\textbf{if} $D_s$ is not marked as \textbf{\textit{eliminated}} \textbf{then}\\
2.~~~~~Mark $D_s$ as \textbf{\textit{non-ISQ}}\\
3.~~~~~\textbf{for each} $D'_s \subset D_s$ such that\\
~~~~~~~~~~~~~~$\exists q \in D_2$ and $q \in D_s$ \textbf{do}\\
4.~~~~~~~~~$NonISQ(D'_s)$\\
5.~~~~~\textbf{end for}\\
6.~\textbf{end if}\\
\hline
\end{tabular}
\caption{NonISQ Function}
\label{topdown_3}
}
\end{table}

Output: enter image description here

2
  • 1
    The contents in the tables look like algorithms. Perhaps one of the algorithm related packages might provide better facilities here?
    – user31729
    Commented Apr 16, 2017 at 18:30
  • 1
    I am editing someone's else code. So have to use tables.
    – silent_dev
    Commented Apr 16, 2017 at 18:36

1 Answer 1

3

If you want to put those tables side by side I think it's necessary to scale them.

\documentclass{book}
\usepackage{graphicx}

\begin{document}
\begin{table}
    \parbox{.45\linewidth}{
        \centering
        \scalebox{.6}{%
        \begin{tabular}{l}
            \hline
            \textbf{Eliminate($D_s$):}\\
            \textbf{Input:} ~Subspace $D_s \subseteq D$\\
            \textbf{Output:} None\\
            \hline
            1.~\textbf{if} $D_s$ is not marked as \textbf{\textit{eliminated}} \textbf{then}\\
            2.~~~~~Mark $D_s$ as \textbf{\textit{eliminated}}\\
            3.~~~~~\textbf{for each} $D'_s \subset D_s$ such that $|D_s|-|D'_s|=1$ \textbf{do}\\
            4.~~~~~~~~~$Eliminate(D'_s)$\\
            5.~~~~~\textbf{end for}\\
            6.~\textbf{end if}\\
            \hline
        \end{tabular}
        }
        \caption{Eliminate Function}
        \label{topdown_2}
    }
    \hfill
    \parbox{.45\linewidth}{
        \centering
        \scalebox{.6}{%
        \begin{tabular}{l}
            \hline
            \textbf{NonISQ($D_1$, $D_2$):}\\
            \textbf{Input:} ~Subspaces $D_1, D_2 \subseteq D$\\
            \textbf{Output:} None\\
            \hline
            1.~Let $D_s = D_1 \cup D_2$\\
            2.~\textbf{if} $D_s$ is not marked as \textbf{\textit{eliminated}} \textbf{then}\\
            2.~~~~~Mark $D_s$ as \textbf{\textit{non-ISQ}}\\
            3.~~~~~\textbf{for each} $D'_s \subset D_s$ such that\\
            ~~~~~~~~~~~~~~$\exists q \in D_2$ and $q \in D_s$ \textbf{do}\\
            4.~~~~~~~~~$NonISQ(D'_s)$\\
            5.~~~~~\textbf{end for}\\
            6.~\textbf{end if}\\
            \hline
        \end{tabular}
        }
        \caption{NonISQ Function}
        \label{topdown_3}
    }
\end{table}
\end{document}

enter image description here

2
  • Can I also add a third table to this?
    – silent_dev
    Commented Apr 17, 2017 at 14:42
  • @user3667569 Of course you can, but I think you have to scale down more, and it could become unreadable. Please, consider to position the three table landscape. If you can't solve the problem, ask a (new) follow-up question, with this one linked.
    – CarLaTeX
    Commented Apr 17, 2017 at 15:12

You must log in to answer this question.

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