0

I have a table that covers horizontally like 1/3 of the page. I want another table next to it and thats working fine by using:

\begin{tabular}[t]{ c | c | c }
    numbers&text&something\\
    1&test&test\\
    2&hello&what\\
\end{tabular}
\begin{tabular}[t]{ c | c | c }
    test&test\\
    1&testing\\
    1&testingagain\\
\end{tabular}

But when I add text to both of the tables to be shown above the tables, it doesnt work:

\textbf{somerandombold}\\
\begin{tabular}[t]{ c | c | c }
    numbers&text&something\\
    1&test&test\\
    2&hello&what\\
\end{tabular}
\textbf{somemorerandombold}
\begin{tabular}[t]{ c | c | c }
    test&test\\
    1&testing\\
    1&testingagain\\
\end{tabular}

The bolded text of the second table just starts horizontally in the middle of the first table and the table itself will go to a whole new line under the first table.

When I remove the linebreak between the bolded text and the second table, it will go next to eachother which I dont want.

I want it like this:

bolded text                         bolded text
numbers|text|something              test|test

etc...

I was thinking about putting the bolded text together on one line and then a line break and then the 2 tables but how would I even line that up the right way then?

But I cant figure out how to get this desired output. What should I do?

2

This code should do more or less what you want:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{eqparbox}
\usepackage{tabularx, booktabs}

\usepackage{amsmath}

\begin{document}

\noindent%
\begin{tabularx}{\linewidth}{@{}X|X@{}|}
  \textbf{somerandombold} & \textbf{somemorerandombold} \\
  \eqmakebox[T1]{ \begin{tabular}[t]{ c | c | c|}
      numbers & text & something \\
      1 & test & test \\
      2 & hello & what
    \end{tabular}} &
  \eqmakebox[T2]{\begin{tabular}[t]{ c | c | c }
      test & test \\
      1 & testing \\
      1 & testingagain
    \end{tabular}} \\
  \addlinespace[3ex]
  \parbox[t]{\eqboxwidth{T1}}{ Random text1 Random text1 Random text1 \\
    Ending random text1\\}
                                             &
  \parbox[t]{\eqboxwidth{T2}}{Random text2 \\
    Ending random text2\\}
\end{tabularx}

\end{document} 

enter image description here

  • I might have forgotten something but I have an error at your first example at the \end{tabularx} Paragraph ended before \begin was complete – Loko Jul 27 '17 at 10:14
  • @Loko: It my fault: I mistyped \begin{tabularx} (forgot the closing brace). – Bernard Jul 27 '17 at 10:17
  • Now Im getting a lot of errors: environment tabular undefined missing number treated as zero illegal unit of measure misplaced alignment tab all at the first 2 lines – Loko Jul 27 '17 at 10:21
  • I suppose you mean ‘tabularx’ undefined. You have to load it with \usepackage, of course. – Bernard Jul 27 '17 at 10:22
  • Is there a way to add a third row underneath it with lines of multiple lines next to eachother? – Loko Jul 27 '17 at 10:32

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.