1

I just can't get my minipage to work. I wanted to put the two tables side by side - the easiest way possible, as my LateX skills are "basic". Therefore, I basically followed the instructions that were provided on how to create a mini page. I just don't know whether a longtable works within them. Also, sffamily is needed as I use a different font in the table than in the text. Any ideas on how to fix this problem? Thx in advance.

\begin{table}[!htb] 
    \caption{Global caption}
    \begin{minipage}{.5\linewidth}
\caption{Caption of longtable}\\
      \centering
 \sffamily 
\scriptsize
\begin{longtable}{lllll}
\hline
0           & 0             & 0 & 0        \\\\\hline 
Example 1           &           &       &   \\\\  
1       & 2     & 3  & 4    \\\\ 
\\hline     
\end{longtable}
}
\end{minipage}%
     \begin{minipage}{.5\linewidth}
\caption{Caption for longtable}\\\\
      \centering
 \sffamily 
\scriptsize
\begin{longtable}{lllll}
\hline
0       & 0             &0  & 0.        \\\\\hline 
Example 2       &           &       &           \\\\  
1       & 2     & 3 & 4 \\\\
\\hline     
\end{longtable}
}
\end{minipage} 
\end{table}
2
  • Welcome to TeX.SE! In you code you fave a mix of LaTeX and HTML code. For start you should remove all HTML commands. In minipage is better encapsulate tabular environment instead of longtable, etc.
    – Zarko
    Feb 19, 2020 at 23:32
  • Sorry, I did not know how to do make new lines, hence, I also changed the number of \\ \hline as it wasn't viewed the right way. A row is finished with \\ (and \hline); so this is viewed wrong here. I will try to change it to tabular
    – Karl L.
    Feb 19, 2020 at 23:36

1 Answer 1

1

After cleaning-up your code, I obtain the following result:

enter image description here

(red lines indicate text border)

\documentclass{article}
\usepackage[skip=1ex,
            labelfont=bf,font=small]{caption}   % <--- new

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}[!htb] 
    \caption{Global caption}
    \begin{minipage}{.5\linewidth}
\caption{Caption of the left table}
    \centering
    \sffamily
 \begin{tabular}{ll ll}
    \hline
0           & 0 & 0 & 0     \\
    \hline
Example 1   &   &   &       \\
1           & 2 & 3 & 4     \\
    \hline
\end{tabular}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\caption{Caption of the right table}
    \centering
    \sffamily
 \begin{tabular}{ll ll}
    \hline
0           & 0 & 0 & 0.    \\
    \hline
Example 2   &   &   &       \\
1           & 2 & 3 & 4     \\
    \hline
\end{tabular}
\end{minipage}
\end{table}
\end{document}

However, I suspect that you like to have two subtable in parallel:

enter image description here

\documentclass{article}
\usepackage[skip=1ex,
            labelfont=bf,font=small]{caption}   % <--- new
\usepackage{subcaption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}[!htb] 
    \caption{Global caption}
    \begin{subtable}[t]{.5\linewidth}
\caption{Caption of the left table}
    \centering
    \sffamily
 \begin{tabular}{ll ll}
    \hline
0           & 0 & 0 & 0     \\
    \hline
Example 1   &   &   &       \\
1           & 2 & 3 & 4     \\
    \hline
\end{tabular}
\end{subtable}%
\begin{subtable}[t]{.5\linewidth}
\caption{Caption of the right table}
    \centering
    \sffamily
 \begin{tabular}{ll ll}
    \hline
0           & 0 & 0 & 0.    \\
    \hline
Example 2   &   &   &       \\
1           & 2 & 3 & 4     \\
    \hline
\end{tabular}
\end{subtable}
\end{table}
\end{document}
1
  • Thank you very much! I hope it was not too much work to clean it up! But makes sense, much better the one you provided! Also did not know about the existence of subtable.
    – Karl L.
    Feb 20, 2020 at 0:12

You must log in to answer this question.

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